FileStream fileStream = File.OpenWrite(@"upload");
while (true)
{
thisRead = networkStream.Read(dataByte, 0, blockSize);
fileStream.Write(dataByte, 0, thisRead);
if (thisRead == 0) break;
}
this code is supposed to write the received file (the file received in bytes stream) to upload folder. the problem is that the code runs with no errors or exceptions but i dont find the file on the pc. is there another way to save the file from the user. it is sent using tcp client and network stream as a byte stream.
Firstly, you should have a
usingstatement:Secondly, if it’s running without error then the code is creating a file somewhere. It’ll be in the working directory of the process. You just need to work out where that is – or specify an absolute filename when creating the stream.