Write to SharedApplicationData?

On OSX 10.9.1, where can I create a file which has to be read- and writeable from 2 applications? One of it will be a console app, running when no user is logged in.

I want to create a console app which then shall be launched by CubeSQL Server’s scheduler. This console app will upload backup files to a server and delete outdated backupfiles.

This console app will read configuration data from a sqlite database and write log info back to it. The configuration data is written from a GUI application, where also the log can be displayed.

I thought I can use SpecialFolder.SharedApplicationData to create a folder for this application and there I would have stored the sqlite database. But it silently fails upon creation. The folder does not get created. (The same code works, when I use SpecialFolder.ApplicationData instead).

[code] Dim f As FolderItem = SpecialFolder.SharedApplicationData.Child(App.kOrganizationName)

If f.Exists = False Then
f.CreateAsFolder
If Not f.Exists Then
MsgBox "ERROR : Cannot create folder : " + nl2 _
+ SpecialFolder.SharedApplicationData.NativePath + “/” + App.kOrganizationName
quit
End If
End If[/code]

When I do the same manually, then I have to enter my credentials before the folder is created.

  1. Is there another place to store such a database file for common access?
  2. Otherwise, how can I authorize the creation of folders and files in SharedApplicationData from code?

Can anyone test this code on Mavericks and tell me whether he could create the test folder or not?

[code] Dim f As FolderItem
f = SpecialFolder.SharedApplicationData.Child(“My Test Folder”)
If Not f.Exists Then
f.CreateAsFolder
End If

If f.Exists Then
f.Launch
Else
SpecialFolder.SharedApplicationData.Launch
MsgBox(“Could not create the test folder”)
End If[/code]

And if not: any idea what is missing?

No it does NOT work on Mavericks (your Msgbox fires)…

try this

SpecialFolder.SharedDocuments

[quote=57044:@Oliver Osswald]Can anyone test this code on Mavericks and tell me whether he could create the test folder or not?
And if not: any idea what is missing?[/quote]

I do not have Mavericks

On Mountain Lion it does not work with
f = SpecialFolder.SharedApplicationData.Child(“My Test Folder”),
but it works with
f = SpecialFolder.ApplicationData.Child(“My Test Folder”)

[quote=57056:@Axel Schneider]I do not have Mavericks

On Mountain Lion it does not work with
f = SpecialFolder.SharedApplicationData.Child(“My Test Folder”),
but it works with
f = SpecialFolder.ApplicationData.Child(“My Test Folder”)[/quote]
Right - however, ApplicationData is within a user’s home folder and only accessible when the user is logged in.

Right now I am going to use SpecialFolder.SharedDocuments, because this seems to be the only place where one can write to, from code (and share with other users or processes).

BTW : Thanks Axel, for testing!

[quote=57048:@Dave S]No it does NOT work on Mavericks (your Msgbox fires)…

try this

SpecialFolder.SharedDocuments[/quote]
Thanks! Yes, figured that out as well. Seems to be the only way to go.