4
Answers

How do I: ReadLine and split columns?

Ask a question
Gustavo

Gustavo

14y
8.6k
1

Hello:
 
I do a ReadLine on a text file and I need to split out the columns so I can populate a dataGrid. The data uses comma seperators. Reason I am not using Jet or ODBC is because it seems these two do not work on x64.
Below is my code, for now:
 
{
String line;
//Pass the file path and file name to the StreamReader constructor
StreamReader sr = new StreamReader("C:\\Test.txt");
//Read the first line of text
line = sr.ReadLine();
//Continue to read until you reach end of file
while (line != null)
{
//write the lie to console window
Console.WriteLine(line);
//Read the next line
line = sr.ReadLine();
// Column1 = ____;
//Column2 = ____;
}
//close the file
sr.Close();
Console.ReadLine();
}

Answers (4)