Page 1 of 1

Reading text lines into an array c#?

Posted: Thu Dec 02, 2010 3:27 am
by chanika
I am writing an app that allows a user to navigate to a .txt file and with the file selected I need it to read the files lines creating a new array member based off each line. (though if you can think of an easier solution please feel free to mention it.)

I am reading the file and using the line count to set the number of array members:
// count the number of lines in a file
newobject.Count = newobject.CountLinesInFile(@newobject.cs?
// create an array with elements for all lines
string[] lines = new string[(newobject.Count)];

How can I tell it to read the line of text UNTIL "\n" or "\r" so that each new line is its own member in the array "lines."
__________________________________
khao san road