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

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


var docsPath = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
var libPath = Path.Combine (docsPath, "..", "Library");

In iOS8 I used this and it worked:

NSFileManager.DefaultManager.GetUrls (NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User) [0].Path

I got this from Xamarin's page about the iOS file system. It says "iOS 8 NOTE: parts of this document are affected by changes in iOS 8. If your application uses Environment.SpecialFolder or calculates relative paths like "../Documents" you should read this tech note from Apple. Updated information is also available at iOS File System Basics."