2
Vote

FS.Current.LocalStorage

description

Hi,

I checked out your code to make see why the root folder under iOS is the Library folder.
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var localAppData = Path.Combine(documents, "..", "Library");
The default on iOS is set to the documents folder which makes sense when looking at apple's documentation.
reference: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

Also, looking at Xamarin's page on handling files using the forms platform: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/files/
Again the default seems to be the documents folder.

Also, In the case we want the Library Folder (specifically for ios), we should be able to write iOS specific code in order to get that folder.
For instance, we might create an SQLite database in the library folder.
But it is important to use of the documents folder for user-generated content (pictures, videos, pdfs, other file types) within the documents folder.
It doesn't make much sense the library applying an overhead to access the library folder only for us to add another in order to get back to the documents folder.

ex:
        Device.OnPlatform(() => {
            string path = PortablePath.Combine (FileSystem.Current.LocalStorage.Path, "..", "Documents");
            Debug.WriteLine (path);
        });
output:
[...]/Containers/Data/Application/6AC0DB67-036A-45E3-B07D-9F7007542AAF/Documents/../Library/../Documents

comments

IoanHancu wrote Jan 13, 2015 at 9:02 PM

Another example of something we should not have to do (eliminating the double backtracking caused by the 2 calls to Combine - first in the library 2nd in app code)
        Device.OnPlatform(() => {
            string path = FileSystem.Current.LocalStorage.Path.Split(new [] {PortablePath.DirectorySeparatorChar + ".."}, StringSplitOptions.RemoveEmptyEntries).First();
        });
It should be (in the case we want the library folder, which is an iOS specific thing)
        Device.OnPlatform(() => {
            string path = PortablePath.Combine (FileSystem.Current.LocalStorage.Path, "..", "Library");
        });