我正在尝试使用FileOpenPicker将照片上传到我的应用程序,当我编写以下代码时:
FileOpenPicker open = new FileOpenPicker();
open.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
open.ViewMode = PickerViewMode.Thumbnail;
// Filter to include a sample subset of file types
open.FileTypeFilter.Clear();
open.FileTypeFilter.Add(".bmp");
open.FileTypeFilter.Add(".png");
open.FileTypeFilter.Add(".jpeg");
open.FileTypeFilter.Add(".jpg");
// Open a stream for the selected file
StorageFile file = await open.PickSingleFileAsync();
// ImageSource im = (new Uri (file.Path));
ChildPic.Source = new BitmapImage(new Uri(file.Path));
它没有给我一个错误,但Image控件留空。
路径中有值:C:\ Users \ Pictures \ New folder(15).jpg
答案 0 :(得分:2)
new BitmapImage(Uri)
不适用于任何路径。它仅支持具有协议URI
,http
,ms-appx
的{{1}}。你必须使用流。
ms-appdata