The output will be like
Showing posts with label C# ReadAllLines method. Show all posts
Showing posts with label C# ReadAllLines method. Show all posts
Sunday, May 6, 2012
Insert CSV File to Array using C#
Read Text File to Array C#/ Insert CSV File to Array using C# / C# Array from Text/CSV Files
ReadAllLines method can be used to read the contents of a CSV file to array. Each line of the text file will become the elements of the array
public void ReadFile2Array()
{
String[] FileContent = File.ReadAllLines(@"C:\Temp\vba.csv");
int LineNo = 0;
foreach (string Line in FileContent)
{
LineNo +=1;
Console.WriteLine("Line " + LineNo.ToString() + " " + Line);
}
}
ReadAllLines method opens a text file, reads all lines of the file into a string array, and then closes the file.
The input file is shown below
The output will be like
Saturday, October 18, 2008
Insert CSV File to Array using C#
Read Text File to Array C#/ Insert CSV File to Array using C# / C# Array from Text/CSV Files
ReadAllLines method can be used to read the contents of a CSV file to array. Each line of the text file will become the elements of the array
public void ReadFile2Array()
{
String[] FileContent = File.ReadAllLines(@"C:\Temp\vba.csv");
int LineNo = 0;
foreach (string Line in FileContent)
{
LineNo +=1;
Console.WriteLine("Line " + LineNo.ToString() + " " + Line);
}
}
ReadAllLines method opens a text file, reads all lines of the file into a string array, and then closes the file.
The input file is shown below
The output will be like
Subscribe to:
Comments (Atom)