テキストファイルから特定の行を抽出し、行を分割してデータをグリッドビューに挿入するコーディングを作成しました。コーディングを以下に示します。
残念ながら、このプログラムを実行すると、"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" というエラー メッセージが表示されます。私のコーディングで何が間違っていたのかを特定するのを手伝ってください
string line;
System.IO.StreamReader file = new System.IO.StreamReader("test.txt");
while ((line = file.ReadLine()) != null)
{
if (line.Contains("DISKXFER"))
{
string dataLine=line.ToString();
string[] split = dataLine.Split(',');
for (int i = 0; i < split.Length; i++)
{
for (int j = 1; j < dataLine.Length; j++)
{
dataGridView1.Rows[j].Cells[i].Value = split[i];
}
}
}
}