1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
public bool LireCompte()
{
string strLine;
string[] strArray;
char[] charArray = new Char[] { ',' };
try
{
FileStream aFile = new FileStream("Comptes.txt", FileMode.Open);
StreamReader sr = new StreamReader(aFile);
strLine = sr.ReadLine();
while (strLine != null)
{
strArray = strLine.Split(charArray);
if (strArray[0] == "S")
{
Epargne e = new Epargne(strArray[1],strArray[2],Convert.ToDouble(strArray[3]));
mesCompteEpargne.AjouterCompteEpargne(e);
}
if (strArray[0] == "C")
{
Cheque e = new Cheque (strArray[1], strArray[2], Convert.ToDouble(strArray[3]));
mesCompteCheque.AjouterCompteCheque(e);
}
if (strArray[0] == "B")
{
Banque e = new Banque(strArray[1], strArray[2], Convert.ToDouble(strArray[3]));
maBanque.AjouterBanque(e);
}
strLine = sr.ReadLine();
}
sr.Close();
Console.ReadLine();
return true;
}
catch (IOException e)
{
Console.WriteLine("Une exeption IO a été jeté!");
Console.WriteLine(e.ToString());
Console.WriteLine();
}
return false;
} |
Partager