【发布时间】:2014-05-20 08:59:50
【问题描述】:
我正在尝试保存使用 FileOpenPicker 选择的图像。 I am lunching this event when an image is selected
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;
我在保存图像时做错了吗?
【问题讨论】:
-
检查stackoverflow.com/questions/19886950/…这基本上是一样的。
-
看到了但没有解决我的问题
-
嗨,你没有做错任何事,一切正常,我已经测试过了。可能是问题不同,或者您在检查时犯了错误。请交叉检查它。在“i = properties.size”的下一行放置一个断点。
-
更新您的问题并添加设置图像。源代码使其保持初始状态..然后它将对其他人有所帮助。
标签: windows-phone-8 storagefile