2015-07-02 70 views
1

我使用FileopenPicker從PictureLibrary但選擇IM不能使用它它FileAccessMode.ReadWrite給我例外在Window Phone 8.1的讀寫模式下圖像無法打開?

Windows.Storage.StorageFile.OpenAsync(FileAccessMode accessmode) 

這是我在讀寫模式下打開文件的代碼,打開後選擇圖像

StorageFile file = args.Files[0]; 
var stream = await file.OpenAsyn(FileAccessMode.ReadWrite); // Exception occur on this line 
BitmapImage bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage(); 
await bitmapImage.setSourceAsyc(stream); 

請幫我這個。

+0

也許你需要將文件複製到你的應用程序存儲和打開寫呢? – Jogy

+0

我試圖複製它,但它仍然給我同樣的accessmode異常無法讀取和寫入,只能與讀取... :( – Wahib

回答

1

只是試圖在一個測試代碼,它的工作對我來說:

StorageFile newFile = await file.CopyAsync(ApplicationData.Current.LocalFolder, file.Name, NameCollisionOption.GenerateUniqueName); 

    using (var stream = await newFile.OpenAsync(FileAccessMode.ReadWrite)) 
    { 

    } 
+0

它的工作,謝謝:) – Wahib

相關問題