m developing an Android app using the Xamarin platform and Im trying to create a folder on my local storage but I have had no success.
First I tried using the System.IO namespace through a FileManager class created by Xamarin Forms Labs. A snippet of the functions I was passing the path of "/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 didn't work so I then opted to using PCLStorage a library for cross platform file operations. I tried this code.
IFolder rootFolder = FileSystem.Current.LocalStorage;
folder = await rootFolder.CreateFolderAsync("wakesocial",
CreationCollisionOption.OpenIfExists);
Didn't work. I navigated to the root of the internal storage and I didn't see the folder.
So the error doesn't seem to be occurring because of the libraries in use but something specific to Android. I have read and write to external storage in manifest. So the question is. Does an app have permission to create a file or folder at the root level of the storage device or does it have to create it at particular location such as in Android/data/packagename
Also used local storage still no files are created.
IFolder rootFolder =FileSystem.Current.LocalStorage;
folder =rootFolder.CreateFolderAsync("media",
CreationCollisionOption.OpenIfExists).Result;