テキスト ファイル (メモ帳の txt ファイル) からデータを読み込んでリスト ボックスに表示する際に問題が発生しています。以下は私のコードですが、なぜデータをロードしないのかわかりません
private void loadData() {
try {
using (StreamReader reader = new StreamReader("visits.txt")) //Reads in file
{
string line;
while ((line = reader.ReadLine()) != null) {
string[] data = line.Split(','); //Splits the lines up when there is a ,
lstDeliveries.Items.Add(data[0] + ", " + data[1] + ", " + data[2]);
lstPickups.Items.Add(data[3] + ", " + data[4]);
}
}
}
catch (FileNotFoundException) {
MessageBox.Show("The file was not found!!"); //Provides error if file not found
Environment.Exit(0); //Closes application
}
}