我正在开发一个 Windows 商店应用程序,我需要在其中上传图像并将其保存在 Assets 文件夹中。我是 C# 新手。这是我的代码。
var picker = new FileOpenPicker();
picker.SuggestedStartLocation = PickerLocationId.Desktop;
picker.ViewMode = PickerViewMode.Thumbnail;
picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".jpeg");
StorageFile file = await picker.PickSingleFileAsync();
if (file == null) return;
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
BitmapImage image = new BitmapImage();
image.SetSource(stream);
imageTargetControl.Source = image;
StorageFolder storageFolder = KnownFolders.DocumentsLibrary;
StorageFile copyFile = await file.CopyAsync(storageFolder);
请帮助我。谢谢