every thing create just fine… except for the last create folder… Unless I specify a name for it, it doesn’t get created
It seems that adding the “a” to it stops it from being created.
I want my backups to be date based so I could have many backups
Is there a workaround?
dim f as folderitem
dim d as date
d=new date
dim a as string
a=str(d.AbbreviatedDate)+" at time "+str(d.ShortTime)
a=a.Replace(",","-")
f=SpecialFolder.Desktop.child("MyApp")
if f.Exists then
else
f.CreateAsFolder
end if
f=SpecialFolder.Desktop.child("MyApp").child("Mass Backups")
if f.Exists then
else
f.CreateAsFolder
end if
f=SpecialFolder.Desktop.child("MyApp").child("Mass Backups").child("Mass Backup from "+a)
if f.Exists then
else
f.CreateAsFolder
end if
Norman already talks abou colon on OS X; same anweer for WIndows for both : and | (probably).
If you do not found on the internet the list of invalid characters in file / folder names for the different OS, you can try to create a folder on your running OS and check a character at a time to know what the OS will told.
On OS X it will tell you it cannot set the file name; on WIndows, a list of weird (illegal) characters is returned.
At last, be aware that some name will enter in conflict with the Xojo IDE. As an example, giving an image file (probably text or anything else too) the name Linux and importing it into the IDE will change the name to Linux1.
At last, a file name that start with a number (one or many numbers) and imported in the IDE will see these numbers cleared from the name.
Checkings have to be done to know if this is still the case with the current Xojo version.
Oh ! Do not create items that have a leading dot character (.): the OS will treat them as invisible files ;-
f=SpecialFolder.Desktop.child("MyApp")
if not f.Exists then
f.CreateAsFolder
end if
//1 less line, easier to read
f=SpecialFolder.Desktop.child("MyApp").child("Mass Backups")
//no need to completely recreate f each time
f=f.child("Mass Backups")
if not f.Exists
... etc
Commas are ok, at least on Windows, but colons and | are not. A “|” is interpreted by the OS as a redirecting pipe and can’t be part of a file or folder name. Replacing the colons with “_” should work, as previously noted.
Alternatively, you can also use
a=a.ReplaceAll(",","-")
a = encodeURLComponent(a)
Which will replace the illegal characters and accented letters by something like
"/ ? < > \ : * | " " replaced by %2F %3F %3C %3E %5C %3A %2A %7C %22 and space by %20.