How to Read byte by byte until EOF?
Hello! I couldn't find an answer on the internet on this question so I guess I will have to ask it.
I am trying to make my own version of WinRar and to avoid using too much RAM I want to read and write the file byte by byte. How do I do it?
Here's the code:
11 Replies
I want to point out I don't seek functions like "ReadAllBytes" or "WriteAllBytes"
FileStream.Read Method (System.IO)
Reads a block of bytes from the stream and writes the data in a given buffer.
ok thanks I will read it
nvm ignore the ping im stupid
FileMode is about how the operating system should open the file. Open it, create a new one and open it, add to an existing file.
FileAccess is about the operations you want to do on that file
I just haven't noticed FileMode Enum does not contain "Write" item or something like that
so I understood how it works
thanks anyway
I used too much python....
:nodd:
If I want to write to file it will clear its contents and move pointer to the beggining right?
When I decide to write something the pointer will be always at the end?
or it depends
It depends on the filemode
understood
also, reading single bytes at a time isn't very efficient
you want a reasonably sized buffer