how get path in Xamarin.iOS and Xamarin.WinPhone??

In Xamarin.Android is :

string folderPath = Environment.ExternalStorageDirectory.AbsolutePath;

But for the others?

Answers

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    iOS and WinPhone apps are sandboxed, so there's generally not any way to get an absolute path to a file.

    What is it that you're trying to accomplish?

  • Luis_dmLuis_dm USMember ✭✭✭

    Is that I'm using PCL Storage (https://components.xamarin.com/view/pclstorage) and need to send the path for the creation of the folder according to the mobile operating system...

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    With PCL Storage, there is no equivalent to Environment.ExternalStorageDirectory. You need to use either FileSystem.Current.LocalStorage or FileSystem.Current.RoamingStorage.

    PCL Storage works within the constraints of the target platform's storage APIs. Since iOS and WinPhone apps are sandboxed, they cannot access anything outside their sandbox or the cloud, so that's what PCL Storage gives you access to. The FileSystem.Current.LocalStorage and FileSystem.Current.RoamingStorage are designed to return the appropriate location based on the platform.

  • CdricLafleurCdricLafleur USMember

    You have to use the dependencyService to abstract the file system for the different platform.

    You can find a start of exemple in the documentation : https://developer.xamarin.com/guides/xamarin-forms/working-with/files/#Loading_and_Saving_Files

    Hope it help you :)

Sign In or Register to comment.