A.Pissicat A.Pissicat - 9 months ago 60
Android Question

Unable to find saved image

I'm very new to Android. I'm working with Xamarin and I have to take a picture with camera and save the picture.

I achieved to take the picture, I have a Bitmap object. Then I save it without error but when I try to find it, there is no file.

There is my code :

Bitmap imgBmp = /* image initialized */

//Save image on folder
var folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var filePath = System.IO.Path.Combine(folderPath, "image1.png");
var stream = new System.IO.FileStream(filePath, FileMode.Create);
bool isOK = imgBmp.Compress(Bitmap.CompressFormat.Jpeg, 95, stream);

I have no error when execute, isOK is true but when I search for the image.png I'm unable to find the file.

With debugger I saw that the path is :
but I can not see that folder.

Can someone help me to find my image1.png ?

Or to change the default folder to something like Pictures\MyApplication\image.png but I don't know how to find default folder for images.

kor kor
Answer Source

Your file is there, but you have no permissions to see it. App directories are only readable to the owning app's uid. If you try to find your file through the shell, your uid is different.

You should try to use another folder path if you want to save file in a world readable location.

I'm just guessing but maybe System.Environment.SpecialFolder.CommonPictures would do.