无法找到已保存的图像

时间:2016-11-14 11:46:37

标签: android xamarin xamarin.android

我对Android很新。我正在和Xamarin合作,我必须用相机拍照并保存图片。

我实现了拍照,我有一个Bitmap对象。然后我保存它没有错误但是当我试图找到它时,没有文件。

有我的代码:

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);
stream.Flush();
stream.Close();

执行时没有错误,isOK为true但是当我搜索image.png时我无法找到该文件。

使用调试器,我看到路径是:/data/user/0/com.myCompagny.MyAppli/files/image1.png,但我看不到该文件夹​​。

有人可以帮我找到我的image1.png吗?

或者将默认文件夹更改为Pictures \ MyApplication \ image.png,但我不知道如何找到图像的默认文件夹。

1 个答案:

答案 0 :(得分:1)

您的文件在那里,but you have no permissions to see it。应用程序目录只能由拥有应用程序的uid读取。如果你试图通过shell找到你的文件,你的uid是不同的。

如果要将文件保存在世界可读的位置,则应尝试使用another folder path

我只是在猜测,但也许会memcpy(one, real, 7);