Freshchris Freshchris - 10 months ago 113
Android Question

Get path to pictures directory

I try to save an Image (Bitmap/byte[]) with my Xamarin.Android app.

I used

private string getPathToFile(string fileName)
File dir = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), "imgen");
if (dir.Exists())

File image = new File(dir, fileName);
return image.Path;

So the returned path looks something like this:


But this path does not exist on the emulator as I checked with the Android Device Monitor.

I read that this folder is some kind of link to a mnt/shell/emulated/... folder, which actually exists on the emulator.

But how can I retrieve this real path in my Application?


I use this code for device:

     path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures).AbsolutePath;
     string myPath= Path.Combine(path, "");

For emulator it is not work.