I am working on developing an HTTP Server/Client and I can currently send small files over it such as .txt files and other easy to read files that do not require much memory. However when I want to send a larger file say a .exe or large .pdf I get memory errors. This are occurring from the fact that before I try to send or receive a file I have to specify the size of my byte[] buffer. Is there a way to get the size of the buffer while reading it from stream?
I want to do something like this:
//Create the stream. private Stream dataStream = response.GetResponseStream(); //read bytes from stream into buffer. byte[] byteArray = new byte[Convert.ToInt32(dataStream.Length)]; dataStream.read(byteArray,0,byteArray.Length); However when calling "dataStream.Length" it throws the error:
ExceptionError: This stream does not support seek operations. Can someone offer some advice as to how I can get the length of my byte[] from the stream?
Thanks,