How to split a large file into chunks in c#?
I'm making a simple file transfer sender and receiver app through the wire. What I have so far is that the sender converts the file into a byte array and sends chunks of that array to the receiver. This works with file of up to 256mb , but anything above, the line: byte[] buffer = StreamFile(fileName); //This is where I convert the file Throws a System out of memory exception. I'm looking for a way to read the file in chunks then write that chunk instead of loading the whole file into a byte . How can I do this with a FileStream ? EDIT: Sorry, heres my crappy code so far: private void btnSend