Read/Write binary file with structure of fixed length
I need to read/write file which as light as possible and with super-fast read and write access. In other words, I cannot use serialization or binary serialization. I have to be able to开发者_运维百科 update a single records and seek in the file quickly.
Essentially, I need a file structure similar to what I would do in C/C++ (i.e. fixed size structure with a defined size that I can read/write on the file and allow me to seek in it). Any idea how to do that in C#?
There is no reason you can't just use the FileStream
or more generally the Stream
class to accomplish this goal. Both of these classes support seeking and reading the raw data from a file without any serialization necessary. Is there a reason this doesn't work for your scenario?
精彩评论