Hi All,
In finishing off a bit of test code I'm doing I have some results shoved to a rich text box. I am trying to add a ',' to the end of each line I am doing the following
StreamWriter sw = new StreamWriter(filePutter.FileName);
sw.WriteLine("Pitstop 2.0 Transparent Data " + DateTime.Now.ToString() + " Serial Number:" + txtSerialNumberRead.Text + ",");
sw.Write(rtbTransparentLog.Text);
this while it saves the data does not give what I need i.e.:
data,
it gives
,data
The rtbox is updated with
rtbTransparentLog.Text +=","+ myComPort.ReadLine();
by placing the comma after rtbTransparentLog.Text +=myComPort.ReadLine()+",";
means the same still happens due to the line feed stuck on the end. Any quickways if getting it in there?
Glenn
Loading
VulpesPosted Mar 6, 2012, 10:43 AM
string[] lines = rtbTransparentLog.Lines;
for (int i = 0; i < lines.Length - 1; i++)
{
lines[i] += ",";
}
rtbTransparentLog.Lines = lines;
Or, if you just want to write a single comma separated line to the file, you could do:
string combined = String.Join(",", rtbTransparentLog.Lines);
Glenn PattonPosted Mar 6, 2012, 10:55 AM