I am developing an Android application using the Xamarin platform and Im trying to create a folder on my local storage, but I have not been successful.
First I tried to use the System.IO namespace through the FileManager class created by Xamarin Forms Labs. A fragment of the functions that I passed along the path "/ storage / emulated / 0 /` ".
public void CreateDirectory(string path) { this.isolatedStorageFile.CreateDirectory(path); } public Stream OpenFile(string path, FileMode mode, FileAccess access) { return (Stream)this.isolatedStorageFile.OpenFile(path, (System.IO.FileMode)mode, (System.IO.FileAccess)access); }
This did not work, so I decided to use the PCLStorage library to work with files in cross-platform files. I tried this code.
IFolder rootFolder = FileSystem.Current.LocalStorage; folder = await rootFolder.CreateFolderAsync("wakesocial", CreationCollisionOption.OpenIfExists);
Does not work. I went to the root of the internal storage and I did not see the folder.
So the error does not seem to be due to the use of libraries, but something special for Android. I read and write to the external storage in the manifest. So the question is. Does the application have permission to create a file or folder at the root level of the storage device or must it be created in a specific place, for example, in Android / data / packagename
android c # xamarin
Joel dean
source share