我可以拍照,但我无法将其保存到KnownFolders
之一。
是的,我已在Package.appxmanifest中声明了图片库访问功能。
var ui = new CameraCaptureUI();
ui.PhotoSettings.CroppedAspectRatio = new Size(4, 3);
StorageFile file = await ui.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (file != null)
{
var stream = await file.OpenAsync(FileAccessMode.Read);
var bitmap = new BitmapImage();
bitmap.SetSource(stream);
Photo.Source = bitmap;
StorageFolder storageFolder = KnownFolders.PicturesLibrary;
var result = await file.CopyAsync(storageFolder, "tps.jpg");
}
代码在最后一行停止。我做错了什么?
答案 0 :(得分:1)
我认为您还需要声明文件类型!