1
我想要創建一個documentlibrary和newfolder使用FileOpenPicker選擇圖像保存createfolder保存選擇圖像中createfolder ...創建一個文件夾,並使用fileopenpicker在Windows 8
我面對錯誤是:
類型的異常「System.Exception的」發生在mscorlib.dll但在用戶代碼
其他信息沒有處理:當文件已存在無法創建文件。 (來自HRESULT的異常:0x800700B7)
如果有這種異常的處理程序,程序可能會安全地繼續。
這是我的代碼:
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
StorageFolder storage = KnownFolders.DocumentsLibrary;
storage = await storage.CreateFolderAsync("New folder", CreationCollisionOption.GenerateUniqueName);
var openpicker = new FileOpenPicker();
openpicker.CommitButtonText = "Upload";
openpicker.FileTypeFilter.Add(".jpg");
openpicker.FileTypeFilter.Add(".jpeg");
openpicker.FileTypeFilter.Add(".png");
openpicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
openpicker.ViewMode = PickerViewMode.List;
file = await openpicker.PickSingleFileAsync();
var imageFile = await StorageFile.GetFileFromPathAsync(file.Path);
IRandomAccessStream rStream = await imageFile.OpenAsync(FileAccessMode.ReadWrite);
Stream stream = rStream.AsStreamForWrite();
if (storage != null)
{
if (file != null)
{
await file.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder);
}
}
}
它的過載,S現在的工作。謝謝你的回答神經元 –