如何使用打开的文件选择器保存facebook,skydrive和本地路径?

时间:2013-02-21 11:11:15

标签: c# image path microsoft-metro filepicker

var filePicker = new FileOpenPicker();
filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
filePicker.ViewMode = PickerViewMode.Thumbnail;
filePicker.FileTypeFilter.Clear();
filePicker.FileTypeFilter.Add(".jpg");
filePicker.FileTypeFilter.Add(".jpeg");
filePicker.FileTypeFilter.Add(".png");

var files = await filePicker.PickMultipleFilesAsync();

if (files != null)
{
    foreach (var file in files)
    {
        using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
        {
            BitmapImage bitmapImage = new BitmapImage();
            bitmapImage.SetSource(fileStream);
            images.Add(bitmapImage);
        }
    }
}
flpView.ItemsSource = images;
loadTimer();

上面的代码正在运行。我可以从本地和facebook等选择多张照片,也可以将选中的图像添加到flipview,但我想存储来自本地,skydrive和facebook图像的图像路径。我想要这个,因为当应用程序启动时,flipview应该自动填充路径中的图像。如果找不到路径,则应在设置超级按钮中更改。这就是主意。但我认为不需要整合facebook。

1 个答案:

答案 0 :(得分:0)

使用选择器打开文件时,您获得的是存储文件而不是传统文件。不同之处在于存储文件不需要具有与之关联的路径。

Windows.Storage.AccessCache提供了缓存存储项以供将来使用的方法。

http://blogs.msdn.com/b/wsdevsol/archive/2012/12/05/stray-from-the-path-stick-to-the-storagefile.aspx 提供了更多相关信息。