StreamReader构造函数中的StackOverflowException

时间:2011-01-29 13:53:05

标签: c# .net streamreader stack-overflow

我的代码有问题;它导致StackOverflowException。错误发生在第StreamReader readFile = new StreamReader(path)行。

任何人都知道如何解决这个问题?谢谢。

public string[,] parseCSV(string path)
{
    List<string[]> parsedData = new List<string[]>();
    try
    {
        using (StreamReader readFile = new StreamReader(path))
        {
            string line;
            string[] row;
            baris = File.ReadAllLines(path).Length;
            row = readFile.ReadLine().Split(',');
            col = row.Length;
            store = new string[baris, col];
            int i = 0;
            int j = 0;

            foreach (string kolom in row)
            {
                store[i, j] = kolom;
                j++;
            }
            i=1;

            while ((line = readFile.ReadLine()) != null)
            {
                row = line.Split(',');
                j = 0;
                foreach (string kolom in row)
                {
                    store[i, j] = kolom;
                    j++;
                }
                i++;
                parsedData.Add(row);
            }
        }
    }
    catch (Exception e)
    {
        //MessageBox.Show(e.Message);
    }
    return store;        
}

1 个答案:

答案 0 :(得分:0)

不幸的是,stackoverflow不会显示调用链。

一直检查这个人的来电者和来电者的来电者。

这家伙不能自己抛弃stackoverflow。