public void readFromCSV() { using (FileStream fs = new FileStream("O:\\TestDaws\\CSDB\\Test2.csv", FileMode.Open, FileAccess.Read)) { using (TextReader sr = new StreamReader(fs)) { string line; while ((line = sr.ReadLine()) != null) { string[] data = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); ListViewItem lvi = new ListViewItem(); lvi.Text = data[0]; lvi.SubItems.Add(data[1]); lvi.SubItems.Add(data[2]); if (data[3] != null) //Index out of range exception thrown here! { lvi.SubItems.Add(data[3]); } listView1.Items.Add(lvi); } } } }
if (data[3] != null)
if (data.Length >= 4)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)