byte[] temp=new byte[100*1024*1024];
if (Save == true) //Check if save Button is marked { byte[] temp1 = new byte[Offset]; Buffer.BlockCopy(temp, 0, temp1, 0, Offset); // copy the contents received on temp[] to temp1[] string res = string.Join("", temp1); // Put all the data streamed to a single string string file_name = "C:\\user\\mady\\desktop\\myData.txt"; // Write the string to mady.txt System.IO.StreamWriter objWriter; objWriter = new System.IO.StreamWriter(file_name); objWriter.WriteLine(res); objWriter.Close(); }
StreamWriter
offset
Open the binary writer output fileStart reading into the byte buffer.When you have enough data, or the device stops sending, then write the buffer to the stream reset the data pointer to the beginning of the bufferIf more data still to process then go back to start readingElseClose the stream file and finish.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)