2011-01-29 34 views
0

我有這個代碼的問題;它導致了StackOverflowException。錯誤發生在行StreamReader readFile = new StreamReader(path)StackOverflowException在StreamReader構造函數

任何人都有一個想法如何解決這個問題?謝謝。

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

什麼`路徑`確實會導致異常? – abatishchev 2011-01-29 13:59:56

回答

0

不幸的是,stackoverflow不會顯示調用鏈。

檢查此人的呼叫者和來電者的呼叫者一路向上。

這個人不能自己拋出stackoverflow。