Author Topic: Writting data from serial port to a file  (Read 9738 times)

waqas

  • Member
  • ***
  • Posts: 1
Writting data from serial port to a file
« on: February 10, 2011, 02:28:55 am »
Hello everyone !

I am trying to modify the code of the serial reading and displaying program ( available at :  http://lvr.com/files/com_port_terminal_cs.zip ) in such a way that it would also write the received data to a text file. I believe I need to integrate the following three code lines at different locations in the original code :

TextWriter tw = new StreamWriter("data.txt");
tw.WriteLine(newReceivedData);
tw.Close();

Can anybody help me in placing these code lines in the original code.
Thanks in advance.
Waqas

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Writting data from serial port to a file
« Reply #1 on: February 12, 2011, 09:36:39 am »
You can write the data to the file any time after receiving it on the serial port and before the variable is overwritten with new received data.

Please note the file location is now http://janaxelson.com/files/com_port_terminal_cs.zip
Jan
« Last Edit: June 22, 2015, 05:15:39 pm by Jan Axelson »

mdlayt

  • Member
  • ***
  • Posts: 40
Re: Writting data from serial port to a file
« Reply #2 on: February 16, 2011, 04:09:51 pm »
And before the variable goes out of scope.