I am trying to allow the user to specify the path for the file that is used to generate an ArrayList, which is then used for a Chart, using the text inputted via a TextBox (the string is in the format of @"C:\filename.csv" which was previously used and worked when the path was hard coded). However, I get an unhandled argument exception error each time the code is executed. How do I go about fixing this error?
private ArrayList readData()
{
logFile = textFilePath.Text;
// initialise an array list for storing the data
ArrayList logData = new ArrayList();
// read every line in the file
using (StreamReader reader = new StreamReader(logFile))
{
string line;
while ((line = reader.ReadLine()) != null)
{
// split the line into a string array using the comma
// delimiter and add to the array list
string[] parts = line.Split(',');
logData.Add(parts);
}
}
// strip the first element from our array list, as this contains
// the header information from our file
logData.RemoveAt(0);
// return the array list containing the file contents
return logData;
}