I am concerned that this code is copying bytes into a temporary buffer before writing directly to file.
I feel like there should be some method of copying bytes directly from the tail end of the main buffer directly to file.
'this code copies all bytes starting at integer index from the main buffer into a new file: ga.exe
'declare temporary buffer
Dim EXEBytes(bytes.Count - index) As Byte
'copy subset of bytes over, starting at index
System.Buffer.BlockCopy(bytes, index, EXEBytes, 0, bytes.Count - index)
'write bytes from temporary array into file
File.WriteAllBytes(Server.MapPath("/BIN/ga.exe"), EXEBytes)
Any ideas?
You would be better off using a stream, I believe: