sabine

sabine

  • NA
  • 11
  • 0

Read attributes from text file

Mar 23 2012 7:25 AM
Hi,
I need to read lines from a .txt or .csv file (not sure yet of the extension) where the data is ';' delimited.
I will use the below code:
int counter = 0;
string line;

// Read the file and display it line by line.
System.IO.StreamReader file =
   new System.IO.StreamReader("c:\\test.txt");
while((line = file.ReadLine()) != null)
{
   Console.WriteLine (line);
   counter++;
}

file.Close();

// Suspend the screen.
Console.ReadLine();

But what I need to know is, on each line I have 4 attributes seperates with ';' how can i read each attribute seperatly and save it in a string value?
Thank you in advance

Answers (3)