Can someone tell me how to Read and Write to Documents Directory in OS X desktop…
thanks in advance…
Can someone tell me how to Read and Write to Documents Directory in OS X desktop…
thanks in advance…
Do you mean your applications Documents Directory or the Documents Directory assigned to the user in MacOS?
The Storage / SaveTable sample writes to the app’s sandboxed Documents directory which is the easiest case.
If you want to publish an app on the Mac App Store and access the user’s Documents directory you’ll need to become familiar with macOS sandboxing. This is a good place to start but it’s an advanced topic.
If you don’t want to publish your app in the Mac App Store then you can just use regular file paths. For example, you can change this line in the Storage / SaveTable sample:
local filePath = system.pathForFile( "data.txt", system.DocumentsDirectory )
to
local filePath = "/Users/bilbo/Documents/data.txt"
and it writes to the Documents directory for user bilbo.
Perry,
“If you want to publish an app on the Mac App Store and access the user’s Documents directory you’ll need to become familiar with macOS sandboxing. This is a good place to start but it’s an advanced topic.”
I went back and revisited your suggestion, it was the correct answer… Thank you for your help.
Roger
Do you mean your applications Documents Directory or the Documents Directory assigned to the user in MacOS?
The Storage / SaveTable sample writes to the app’s sandboxed Documents directory which is the easiest case.
If you want to publish an app on the Mac App Store and access the user’s Documents directory you’ll need to become familiar with macOS sandboxing. This is a good place to start but it’s an advanced topic.
If you don’t want to publish your app in the Mac App Store then you can just use regular file paths. For example, you can change this line in the Storage / SaveTable sample:
local filePath = system.pathForFile( "data.txt", system.DocumentsDirectory )
to
local filePath = "/Users/bilbo/Documents/data.txt"
and it writes to the Documents directory for user bilbo.
Perry,
“If you want to publish an app on the Mac App Store and access the user’s Documents directory you’ll need to become familiar with macOS sandboxing. This is a good place to start but it’s an advanced topic.”
I went back and revisited your suggestion, it was the correct answer… Thank you for your help.
Roger