我正在尝试保存使用 FileOpenPicker 选择的图像。选择图像时,我正在为这个活动提供午餐
async void photoChooserTask_Completed(object sender, PhotoResult e)
{
// get the file stream and file name
Stream photoStream = e.ChosenPhoto;
string fileName = Path.GetFileName(e.OriginalFileName);
// persist data into isolated storage
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
using (Stream current = await file.OpenStreamForWriteAsync())
{
await photoStream.CopyToAsync(current);
}
}
但是这段代码会给我保存文件的长度返回 0
var properties = await file.GetBasicPropertiesAsync();
i = properties.Size;
我在保存图像时做错了什么吗?