Greetings,
the current API for System.IO.WriteAllBytesAsync only supports byte[] as an input.
This prevents the usage of other buffer formats such as ImmutableArray<>.
It would be great if we had an additional overload with IEnumerable<byte> for both the Async and the Sync version of write all bytes, just as System.IO.WriteAllTextAsync does.
I imagine one of the problems with that API would be that you'd need to still enumerate the bytes to write them in a block or write each byte individually and that would be slow.
Your best bet for ImmutableArray<byte> is probably ImmutableArray<byte>.AsMemory() and FileStream.WriteAsync(ReadOnlyMemory<Byte>, CancellationToken).
This question has been answered, so I'm closing the issue. If you feel this has been closed incorrectly then please reopen and add more info. Thanks!
Most helpful comment
I imagine one of the problems with that API would be that you'd need to still enumerate the bytes to write them in a block or write each byte individually and that would be slow.
Your best bet for
ImmutableArray<byte>is probablyImmutableArray<byte>.AsMemory()andFileStream.WriteAsync(ReadOnlyMemory<Byte>, CancellationToken).