我有以下代码应该检索画布,保存图像,然后将文件属性写入其中。可悲的是,它在尝试保存属性时崩溃了。它们是字符串形式,属性也需要一个字符串,所以我看不出可能出错的地方:
try
{
using (Windows.Storage.Streams.IRandomAccessStream stream =
await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
{
stream.Size = 0;
await MyInkCanvas.InkPresenter.StrokeContainer.SaveAsync(stream);
}
ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();
string title = CanvasGrid.Width + " x " + CanvasGrid.Height;
imageProperties.Title = title;
await imageProperties.SavePropertiesAsync();
//MainPage.NotifyUser("File has been saved!", NotifyType.StatusMessage);
}
catch (Exception ex)
{
//MainPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
}
价值不在预期范围内。