简体   繁体   English

StreamReader构造函数上的StackOverflowException

[英]StackOverflowException at StreamReader constructor

I have a problem with this code; 我的代码有问题; it caused StackOverflowException. 它导致了StackOverflowException。 The error occurred in line StreamReader readFile = new StreamReader(path) . 该错误发生在StreamReader readFile = new StreamReader(path)

Anyone have an idea how to solve this problem? 有人知道如何解决这个问题吗? Thank you. 谢谢。

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;        
}

Unfortunately stackoverflow doesn't present the call chain. 不幸的是stackoverflow不能显示调用链。

Check this guy's callers and callers of his callers all the way up. 一直检查此人的呼叫者和呼叫者的呼叫者。

This guy can't throw stackoverflow by himself. 这个家伙不能自己抛出stackoverflow。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM