DataWriter.StoreAsync() 在 WASM 上不可用

DataWriter.StoreAsync() not available on WASM

我在 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();
    }
}

当我针对 wasm 进行测试时,我收到:

fail: Windows.Storage.Streams.DataWriter[0]
    The member DataWriter.DataWriter(IOutputStream outputStream) is not implemented in Uno.

我的 try-catch 给我: System.NullReferenceException:Arg_NullReferenceException 在 Windows.Storage.Streams.DataWriter.WriteBytes[Byte[] 值)...第 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 is not implemented 此时流。

您应该可以使用 .AsStreamForWrite() extension method and use a .NET StreamWriter instead

Uno Platform 通常选择基于 .NET APIs 中等效 API 的存在来实现 WinRT APIs,这就是为什么像这样的部分是还没有。