private void Start() { string path = string.Format(@"{0}\accountLog", Environment.CurrentDirectory); DirectoryInfo directory = new DirectoryInfo(path); if (directory.Exists && directory.GetFiles().Length > 0) { FileInfo file = directory.GetFiles()[0]; string[] bankInfo = file.Name.Split('-'); int money = 0; using (StreamReader sr = new StreamReader(file.FullName)) { money = Convert.ToInt32(sr.ReadLine()); } bankAccount = new Model.BankAccount() { PrimaryName = bankInfo[0], UserName = bankInfo[1].Replace(".txt", ""), Money = money }; Console.WriteLine("이미 계좌가 있습니다.\n"); } }
private void Start() { string logFilePath = string.Format(@"{0}\bankLog", Environment.CurrentDirectory); DirectoryInfo directory = new DirectoryInfo(logFilePath); if (directory.Exists && directory.GetFiles().Length > 0) //폴더랑 파일 있으면 { FileInfo file = directory.GetFiles()[0]; //뱅크로그 string[] bankInfo = file.Name.Split('-'); //계좌명-사람이름이 파일명이고 내용은 잔액인가봄 int money = 0; using (StreamReader sr = new StreamReader(file.FullName)) { money = Convert.ToInt32(sr.ReadLine()); //내용은 잔액! } bankAccount = new Model.BankAccount() { PrimaryName = bankInfo[0], //계좌명 UserName = bankInfo[1].Replace(".txt", ""), //.txt 빼고 사람이름 Money = money }; Console.WriteLine("이미 계좌가 있습니다"); } }
private void CreateAccount(string primaryName, string userName) { bankAccount = new Model.BankAccount() { PrimaryName = primaryName, UserName = userName, Money = 0 }; Console.WriteLine("계좌가 개설되었습니다.\n"); }
private void CreateAccount(string primaryName, string userName) { bankAccount = new Model.BankAccount() { PrimaryName = primaryName, UserName = userName, Money = 0 }; Console.WriteLine("'{0}'님의 '{1}'이 개설되었습니다.", bankAccount.UserName, bankAccount.PrimaryName); }