What is the correct way to get the iOS Library folder using Xamarin.iOS?

Viewed 9484

This will get me my iOS app's document root:

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

Is there something similar to get to the Library folder?

3 Answers

Currently (iOS 12) you can retrieve the Library path via:

var libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Resources);

".../APP-UUID/Library"

For directories nested within the Library folder, such as the local app cache, you can do:

var pathToCache = Path.Combine(libraryPath, "Caches"); 

".../APP-UUID/Library/Caches"

Additional directories on Xamarin IOS that may be of interest:

SpecialFolder.Favorites =   ".../APP-UUID/Library/Favorites"
SpecialFolder.MyDocuments = ".../APP-UUID/Documents"
SpecialFolder.MyMusic =     ".../APP-UUID/Documents/Music"
SpecialFolder.MyPictures =  ".../APP-UUID/Documents/Pictures"
SpecialFolder.MyVideos =    ".../APP-UUID/Documents/Videos"
SpecialFolder.Desktop =     ".../APP-UUID/Documents/Desktop"

More options can be explored on the Xamarin Docs for File System

Related