In the previous post, I had difficulty accessing fields separated by comma in "~" separated rows.
Example "a,b,c~d,e,f~g,h,i~"
But after writing the output
I get the following result:
"a,b,c~
a,b,c~
d,e,f~
a,b,c~
d,e,f~
g,h,i~"
my desired result is as below:
"a,b,c~
d,e,f~
g,h,i~"
Any help is appreciated. Thanks!
using (StreamWriter write = new StreamWriter(filePath, true))
{
string[] line = strInput.Split('~');
foreach (string part in line)
{
string[] strField = part.Split(',');
strDetails += strField[0] + "," + strField[5] + "," + strField[1] + "," + strField[2] + "," + strField[4] + "~";
string[] strDetail = strDetails.Split('~');
foreach (string parts in strDetail)
{
write.WriteLine(parts);
}
}
Any