The output will be like
Sunday, May 6, 2012
Insert CSV File to Array using C#
The output will be like
Saturday, November 1, 2008
Check if file exists using C# (.NET)
Check Existence of File using C# (.NET)
Exists method of the System.IO.File class can be used to check if a file exists in a given location.
private static bool Check_file_Existence(string sFileName)
{
try
{
if (File.Exists(sFileName) == true)
{return true;
}
else
{ return false; }
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
, IsExist Method in .NET, .NET File Class, .NET Exists Method
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