dim f As FolderItem
dim stream as textOutputStream
f = SpecialFolder.Preferences.child("XojoTestFile")
stream = f.CreateTextFile
stream.writeLine "File test"
stream.close
“works” because I can read it with stream.readLine - but I can’t find it in the Preferences folder. So where is it? What is the path to see where it is saved?
I am using High Sierra.
[quote]/Users/UserName/Library/Preferences
On macOS, use SpecialFolder.ApplicationData to save your own files or directly call CFPreferences to save preferences files here.[/quote]
Also, try running the Xojo Example, under the File>New>Examples>Files>SpecialFolderPaths, this will list all the locations of special folder end points.
If f <> Nil Then
If f.exists Then
Like I’ve used before, or at the other hand, had added to the code very rigorously now.
From the TextOutputStream linked above, it seems I would need to add the Try statement when attempting to save a newly created file then?
Dim f As FolderItem = Documents.Child("Sample.txt")
If f <> Nil Then
Try
Catch e As IOException
// handle
End Try
NIL indicates the folderobject is not valid (either never been assigned, or has a path name that cannot legally exist)
Not Exists indicates the folderobject IS valid, but the named file is not located
So for a “newly created” file, NIL means you will fail if you attempt to create it
Exists can be used to check if you will over-write a previous file
I don’t understand why the last 4 posts are in the conversation I started. And nobody has answered the question I posed: where is the file I created? It is not in the Preferences folder.
On macOS, writing directly to the Preferences folder is frowned upon by Apple… If you want your preferences file to end up there, you need to use CF/NSPreferences, or write your code to save the file to the Application Support folder…