【发布时间】:2014-08-04 17:37:23
【问题描述】:
我正在尝试使用 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));
它没有给我一个错误,但图像控件留空。
路径中有值:C:\Users\Pictures\New folder(15).jpg
【问题讨论】:
-
在
ChildPic.Source = new BitmapImage(new Uri(file.Path));处打断点检查是否有路径值。让我们知道它给了什么...... -
路径中有值:C:\Users\Pictures\New folder(15).jpg
标签: c# image microsoft-metro winrt-xaml windows-8.1