텍스트 파일 (메모장 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
}
}
그리고 질문은 ... –
당신은 적어도 문제의 설명, 난 당신이 라인은'시스템 아무것도를 보유하고 있는지 확인하기 위해 디버그 문을 추가 할 수 있습니다 – horgh
를 제공 할 수있다. Diagnostics.Debug.WriteLine (line); ' – littledevils326