Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 366
Krumelur Avatar asked Dec 11 '13 11:12

Krumelur


People also ask

Where is xamarin iOS located?

Xamarin. iOS (Visual Studio for Mac): /Library/Frameworks/Xamarin.

Which library is used in xamarin?

For Xamarin. Forms it supports PCL (Portable Class Library), Android, iOS, and UWP (Universal Windows Project).

How do I create a folder in xamarin?

You can use dependenceService to create a folder and a file in device internal storage. First, create an interface in your PCL. Invoke this dependenceService in button click event or other method. Then achieve it in Android folder.

What is info plist in xamarin iOS?

The Info. plist contains special sections to specify maps integration and backgrounding modes. Choosing the options you want to support will add the required properties to your application for you. For more information on working with maps, refer to the Xamarin iOS Maps guide.


3 Answers

var docsPath = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
var libPath = Path.Combine (docsPath, "..", "Library");
like image 154
CinnamonBun Avatar answered Nov 01 '22 19:11

CinnamonBun


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

like image 30
ToddBFisher Avatar answered Nov 01 '22 20:11

ToddBFisher


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."

like image 41
Lereveme Avatar answered Nov 01 '22 20:11

Lereveme