0

.txtファイルからデータを読み取って、クラス インスタンスのリストに配置しようとしています。ReadLine()デバッグ中に、コマンドが.txtファイルの行をスキップしていることに気付きました。なぜこれが起こっているのか、状況を改善する方法を知っている人はいますか?

string logPath;
string defaultPath;
string line;

OpenFileDialog openLog = new OpenFileDialog();
openLog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";

if (openLog.ShowDialog() == DialogResult.OK)
{
    logPath = openLog.FileName;
    logTextBox.Text = logPath;
    defaultPath = logPath.Substring(0, logPath.LastIndexOf("\\"));

    StreamReader logStream = new StreamReader(logPath);

    while (!logStream.EndOfStream)
    {
        line = logStream.ReadLine();
        Console.WriteLine(line);
    }
}
4

0 に答える 0