Saturday, May 30, 2009

File Content To Array

private ArrayList fileContentToArrayList(string filePath)
{

System.Collections.ArrayList arrListLines = new System.Collections.ArrayList();
//read the file content one by one
try
{
StreamReader fl = new StreamReader(filePath, System.Text.Encoding.ASCII);
//StreamReader fl = File.OpenText(filePath,);
string line = "";
while((line = fl.ReadLine()) != null )
{
arrListLines.Add(line);
}


}
catch(Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message, "Failed reading file");
return null;
}
return arrListLines;
}

No comments:

Post a Comment