native localFolder vs Corona's system.DocumentsDirectory

I’m having problems with finding a json file that I’m saving to system.DocumentsDirectory in CoronaCards.
I can find it from Corona call, of course, but when I try to find it natively in c# - I catch an exception.
Tried to save to system.ResourceDirectory but got same results.

Where should I save/look for my file to make it visible for native environment?

You can fetch Corona’s default paths via our CoronaRuntimeEnvironment class’ static properties…
   http://docs.coronalabs.com/daily/native/wp8/html/html/T_CoronaLabs_Corona_WinRT_CoronaRuntimeEnvironment.htm
 
For example, the following will return Corona’s default path to the system.DocumentsDirectory in C#…

string documentsDirectoryPath = CoronaLabs.Corona.WinRT.CoronaRuntimeEnvironment.DefaultDocumentsDirectoryPath;

You can also change the paths you want Corona to use for these directories on startup (ie: in your MainPage) by calling fCoronaPanel.Runtime.RunUsing() and passing in your custom launch settings.
   http://docs.coronalabs.com/daily/native/wp8/html/html/M_CoronaLabs_Corona_WinRT_CoronaRuntime_RunUsing.htm

Also, you cannot write to the system.ResourceDirectory on WP8… or iOS and Android.  It’s a read-only directory.

However, on WP8, we do give you the option to change the resource directory via RunUsing() to a path that is writeable, but that was intended for developers who download their Corona projects to the device, such as Adobe Flash style apps.

Cool, thanks! I’ll check it out.

One more thing.  I recommend that you use .NET’s System.IO.Path.Combine() method to combine the path with your file name.  That way you don’t have to worry about trailing slashes.  That said, Corona will always remove the trailing slash from these directories, even if you provide your own custom path with a trailing slash via our RunUsing() method, we still remove the trailing slash.

Joshua, could you write an example how to set Corona Documents folder to ApplicationData.Current.LocalFolder, please? I’m a newbie to C# and I’m not sure how to set it properly… :confused:

Sure.  Add the following line of code to the bottom of your MainPage’s constructor.

fCoronaPanel.AutoLaunchSettings.DocumentsDirectoryPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;

The above will change Corona’s system.DocumentsDirectory to your WP8 app’s root data folder.  By default, we set the documents directory to a “Corona\Documents” subdirectory under the above location.

Now, since your app is set up to be auto-launched because your constructor has the following line…

   fCoronaPanel.AutoLaunchEnabled = true

…then Corona will use the “AutoLaunchSettings” by default and you do not have to use our CoronaPanel.Runtime.RunUsing() method.

It works - I can find the file now. Thanks!

You can fetch Corona’s default paths via our CoronaRuntimeEnvironment class’ static properties…
   http://docs.coronalabs.com/daily/native/wp8/html/html/T_CoronaLabs_Corona_WinRT_CoronaRuntimeEnvironment.htm
 
For example, the following will return Corona’s default path to the system.DocumentsDirectory in C#…

string documentsDirectoryPath = CoronaLabs.Corona.WinRT.CoronaRuntimeEnvironment.DefaultDocumentsDirectoryPath;

You can also change the paths you want Corona to use for these directories on startup (ie: in your MainPage) by calling fCoronaPanel.Runtime.RunUsing() and passing in your custom launch settings.
   http://docs.coronalabs.com/daily/native/wp8/html/html/M_CoronaLabs_Corona_WinRT_CoronaRuntime_RunUsing.htm

Also, you cannot write to the system.ResourceDirectory on WP8… or iOS and Android.  It’s a read-only directory.

However, on WP8, we do give you the option to change the resource directory via RunUsing() to a path that is writeable, but that was intended for developers who download their Corona projects to the device, such as Adobe Flash style apps.

Cool, thanks! I’ll check it out.

One more thing.  I recommend that you use .NET’s System.IO.Path.Combine() method to combine the path with your file name.  That way you don’t have to worry about trailing slashes.  That said, Corona will always remove the trailing slash from these directories, even if you provide your own custom path with a trailing slash via our RunUsing() method, we still remove the trailing slash.

Joshua, could you write an example how to set Corona Documents folder to ApplicationData.Current.LocalFolder, please? I’m a newbie to C# and I’m not sure how to set it properly… :confused:

Sure.  Add the following line of code to the bottom of your MainPage’s constructor.

fCoronaPanel.AutoLaunchSettings.DocumentsDirectoryPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;

The above will change Corona’s system.DocumentsDirectory to your WP8 app’s root data folder.  By default, we set the documents directory to a “Corona\Documents” subdirectory under the above location.

Now, since your app is set up to be auto-launched because your constructor has the following line…

   fCoronaPanel.AutoLaunchEnabled = true

…then Corona will use the “AutoLaunchSettings” by default and you do not have to use our CoronaPanel.Runtime.RunUsing() method.

It works - I can find the file now. Thanks!