I need behaviour similar to Java’s RandomAccessFile(path, "rws") method, namely flushing data to disk as soon as it is written to the file.
I lean towards using BinaryWriter for my purposes, but it doesn’t have a way to specify the flushing behaviour.
Any suggestions?
BinaryWriteris notsealed, and all of theWritemethods arevirtual. You could override them and add a call toFlush, for example:However! In most cases this would be really bad for performance. I don’t recommend it.
If you are using a
StreamWriteror similar, then just setAutoFlushtotrue; job done; but again – this could really hurt performance.