从IO.Stream对象获取图像的路径

时间:2013-07-19 18:23:50

标签: c# image xaml stream windows-phone-8

我正在编写一个Windows Phone 8应用程序,我需要允许用户在应用程序中使用他们的相机胶卷中的图像。通过从BitmapImage的所选照片中制作PhotoChooserTask,我可以让图片显示得很好,但是当用户离开应用时,我不知道如何将图像的URI保存到应用程序。

也许我只是盲目且无法在文档中找到该属性,但是我可以在任何地方找到图像的URI,以便以后可以将其加载到Image控件中吗?

1 个答案:

答案 0 :(得分:2)

PhotoResult返回的PhotoChooserTask通过OriginalFileName属性公开文件名。

OriginalFileName只是一个字符串,可用于构建URI。如果您如上所述,您需要获取路径信息,则可以使用System.IO.Path例如

string filename = YourPhotoResult.OriginalFileName;
System.IO.Path.GetDirectoryName(filename) // Gets the directory the file is located in

以下是PhotoResult类的MSDN链接: http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.tasks.photoresult(v=vs.105).aspx