User13839404 User13839404 - 1 year ago 104
C# Question

How to read text file by particular line separator character?

Reading a text file using streamreader.

using (StreamReader sr = new StreamReader(FileName, Encoding.Default))
string line = sr.ReadLine();

I want to force that line delimiter should be
. So how can i do that?

Answer Source
string text = sr.ReadToEnd();
string[] lines = text.Split('\r');
foreach(string s in lines)
   // Consume
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download