Kedaessa
Messages postés30Date d'inscriptionsamedi 28 février 2004StatutMembreDernière intervention17 mai 2005
-
16 mars 2004 à 20:30
cs_coq
Messages postés6349Date d'inscriptionsamedi 1 juin 2002StatutMembreDernière intervention 2 août 2014
-
16 mars 2004 à 21:58
Salut ! J'ai écris un bout de code qui est sensé repèrer si un fichier existe, sinon le créer, puis le lire et classer dans un tableau...
string lmfi = "" /* Chemin du fichier */
string[][] Lst;
/* Plus loin */
FileInfo Verif = new FileInfo(lmfi);
if(!Verif.Exists)
{
StreamWriter sw = Verif.CreateText();
sw.WriteLine("END");
sw.Close();
}
StreamReader sr = Verif.OpenText();
string Rd;
int first,last;
for(int i=0;i==i;i++)
{
Rd=sr.ReadLine();
if(Rd=="END")
{
break;
}
else
{
first = Rd.IndexOf(Rd,0);
last = Rd.IndexOf(Rd,first+1);
Lst[i][0] = Rd.Substring(0,first);
Lst[i][1] = Rd.Substring(first+1,last);
Lst[i][2] = Rd.Substring(last+1,Rd.Length);
}
}
sr.Close();
for(int i=0; i < Lst.Length; i++)
{
list.Items.Add(Lst[i][0] +" - "+ Lst[i][1]);
}
J'obtient une erreur sur "first = Rd.IndexOf(Rd,0);" je sais pas pourquoi.... l'erreur est : "Une exception non gérée du type 'System.NullReferenceException' s'est produite.
Informations supplémentaires : La référence d'objet n'est pas définie à une instance d'un objet."