I am trying to read a text file line by line and create one line from multiple lines until the line read in has \r\n at the end. My data looks like this:
BusID|Comment1|Text\r\n
1010|"Cuautla, Inc. d/b/a 3 Margaritas VIII\n
State Lic. #40428210000 City Lic.#4042821P\n
9/26/14 9/14/14 - 9/13/15 $175.00\n
9/20/00 9/14/00 - 9/13/01 $575.00 New License"\r\n
1020|"7-Eleven Inc., dba 7-Eleven Store #20638\n
State Lic. #24111110126; City Lic. #2411111126P\n
SEND ISSUED LICENSES TO DALLAS, TX\r\n
I want the data to look like this:
BusID|Comment1|Text\r\n
1010|"Cuautla, Inc. d/b/a 3 Margaritas VIII State Lic. #40428210000 City Lic.#4042821P 9/26/14 9/14/14 - 9/13/15 $175.00 9/20/00 9/14/00 - 9/13/01 $575.00 New License"\r\n
1020|"7-Eleven Inc., dba 7-Eleven Store #20638 State Lic. #24111110126; City Lic. #2411111126P SEND ISSUED LICENSES TO DALLAS, TX\r\n
My code is like this:
FileStream fsFileStream = new FileStream(strInputFileName, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
using (StreamReader srStreamRdr = new StreamReader(fsFileStream))
{
while ((strDataLine = srStreamRdr.ReadLine()) != null && !blnEndOfFile)
{
//code evaluation here
}
I have tried:
if (strDataLine.EndsWith(Environment.NewLine))
{
blnEndOfLine = true;
}
and
if (strDataLine.Contains(Environment.NewLine))
{
blnEndOfLine = true;
}
These do not see anything at the end of the string variable. Is there a way for me to tell the true end of line so I can combine these rows into one row? Should I be reading the file differently?