0

I would like to write string list items into a single line.At the moment when I do the write,it breaks the line with newline feeds with multiple lines.See section from code below:

List<String> stringList = new List<String>();

stringList.Add(line1);

while (line2 != null)
{
  if ( line1.Length >= 8 && line2.Length >= 8 && line1.Substring(0,8) == line2.Substring(0,8) )
  {
    stringList.Add(line2);
  }
  line2 = fileread2.ReadLine();
  counter2++;
}
// string outcome = string.Join(",", stringList);
filewrite.WriteLine( stringList.Aggregate((current,next) => string.Format("{0}, {1}", current, next)));

The code above includes a streamreader and streamwritwer.
The input is 200mb text file.The output is also a text file, but my intetion is to make it display grouped data per line.The problem is the line is too long,so it gets displayed with newline feeds. i need it displayed as single line per group on notepad txt regardless of how long it is,instead of multiple lines.i have tried join,concatenate,array but still not working. Please Advise.

3
Contributors
4
Replies
25
Views
2 Years
Discussion Span
Last Post by ondegotariq
0

If I'm not mistaken , you are using WriteLine instead of just Write .
Your goal is actually just to write everything in a single line?

0

Yes,to write as one continous line.i also tried Write but that did not do the trick either.

0

Thanks guys i found the solution,apparently notepad does not support lines longer than 1024 characters.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.