Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Thanks for looking at my questions

I am able to append text to a document using stream writer. However if makes a new line each time i append data. I would like it to append data to the same line.
Is this even possible?? Here is the code were I am doing the writing.
String^ data = serialPort1->ReadExisting();
StreamWriter^ sw= File::AppendText(fileloc->Text);
sw->WriteLine(data);
                   

sw->Flush();
sw->Close();
Posted

1 solution

You need to change
String^ data = serialPort1->ReadExisting();
StreamWriter^ sw= File::AppendText(fileloc->Text);
sw->WriteLine(data);

sw->Flush();
sw->Close();


to

String^ data = serialPort1->ReadExisting();
StreamWriter^ sw= File::AppendText(fileloc->Text);
sw->Write(data);

sw->Flush();
sw->Close();


I suggest you look here as well for other functions you might have missed.

http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx[^]
 
Share this answer
 
Comments
Member 7796364 15-Apr-11 12:21pm    
Thanks very much for the fast reply. This works nicely

I should of been able to find that, sorry for not looking hard enough. I was thinking I had to manipulate WriteLine instead of using something else.
Sergey Alexandrovich Kryukov 15-Apr-11 15:05pm    
Sure, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900