J'ai un problème avec ce code; il a causé StackOverflowException. L'erreur s'est produite à la ligne StreamReader readFile = new StreamReader(path)
.StackOverflowException au constructeur StreamReader
Est-ce que quelqu'un a une idée comment résoudre ce problème? Je vous remercie.
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;
}
Quel 'path' provoque une exception? – abatishchev
Lorsque l'erreur se produit, affichez la fenêtre de la pile d'appels dans l'EDI et dites-nous à quoi elle ressemble - quelle fonction appelée parseCSV et combien de fois? Quelle est la valeur dans la variable "path"? StreamReader est-il la classe d'infrastructure .NET ou avez-vous créé votre propre SteramReader? – BlueMonkMN
Le constructeur StreamReader que vous utilisez ne lance jamais une exception StackOverflowException. Pouvez-vous poster une trace de pile? –