I'd like to read and write bytes and structured value types, asynchronously, without having to worry about decoders and byte-shifting: is there something out there that would allow me to do that?
You can use FileStream
, make sure you call the constructor properly so it enables async and has a large enough buffer.
var buffer = new byte[2048];
using var r = new FileStream(
Path,
FileMode.Open,
FileAccess.ReadWrite,
FileShare.None,
2048000,
FileOptions.Asynchronous);
await r.ReadAsync(buffer, 0, 2048);
await r.Writesync(buffer);
Now that you have a byte array you can have three options to convert them to objects:
BitConverter
BinaryFormatter
and MemoryStream
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With