我在WASM上使用Uno应用程序从我的网站下载图像时遇到问题平台。
它对UWP有效。我的代码是:
StorageFile imageFile = await SelectedFolder.CreateFileAsync($"{item.picturekey}.jpg",
Overwrite ? CreationCollisionOption.ReplaceExisting : CreationCollisionOption.FailIfExists);
if (imageFile != null)
{
byte[] imageArray = await DataService.GetImage(item.picturekey, item.hiresurl);
if (imageArray != null)
{
var stream = await imageFile.OpenAsync(FileAccessMode.ReadWrite);
using (var outputStream = stream.GetOutputStreamAt(0))
{
using (DataWriter writer = new DataWriter(outputStream))
{
if (imageArray != null)
{
sb.AppendLine(this.DownloadStatus);
await writer.StoreAsync();
await outputStream.FlushAsync();
}
}
}
stream.Dispose();
}
}
当我对asm进行测试时,我收到:
fail: Windows.Storage.Streams.DataWriter[0]
The member DataWriter.DataWriter(IOutputStream outputStream) is not implemented in Uno.
我的try-catch给我:系统。NullReferenceException:在Windows.Storage.Streams.DataWriter上的Arg_NullReferenceException。WriteBytes[Byte[] value)…第62行
I have checked to be sure, imageArray.Length > 0, so I am not passing in a null.
I assume that it is really supported in Uno for UWP and not WASM, is there a work-around?
Thanks, any suggestions would be helpful.
DataWriter
目前还没有实现。
你应该能够使用.AsStreamForWrite()
扩展方法和使用。netStreamWriter
代替。
Uno平台通常选择基于。net API中等效API的存在来实现WinRT API,这就是为什么像这一部分还不可用的原因。