public static bool WriteStructInFile(UserMailFacts facts) { string folderPath = Environment.ExpandEnvironmentVariables(AppConst.APP_DATA_FOLDER); string filePath = folderPath + "\\" + AppConst.USER_CONFIG_FILE_NAME; CreateFolderAndFile(); try { using (FileStream fileStream = File.Open(filePath, FileMode.Open)) { using (BinaryWriter writer = new BinaryWriter(fileStream)) { writer.Write(facts.UserName); writer.Write(facts.EmailAdress); writer.Write(facts.Login); writer.Write(facts.SmtpAdress); writer.Write(facts.ImapAdress); writer.Write(facts.EncodingText.Length); writer.Write(facts.EncodingText); writer.Write(facts.Entropy); } } return(true); } catch (FileNotFoundException e) { Console.WriteLine(e.ToString()); } return(false); }
public static UserMailFacts ReadStructInFile() { string folderPath = Environment.ExpandEnvironmentVariables(AppConst.APP_DATA_FOLDER); string filePath = folderPath + "\\" + AppConst.USER_CONFIG_FILE_NAME; UserMailFacts userFacts = new UserMailFacts(); using (FileStream fileStream = File.Open(filePath, FileMode.Open)) { using (BinaryReader reader = new BinaryReader(fileStream)) { userFacts.UserName = reader.ReadString(); userFacts.EmailAdress = reader.ReadString(); userFacts.Login = reader.ReadString(); userFacts.SmtpAdress = reader.ReadString(); userFacts.ImapAdress = reader.ReadString(); int count = reader.ReadInt32(); userFacts.EncodingText = reader.ReadBytes(count); userFacts.Entropy = reader.ReadBytes(20); } } return(userFacts); }
public MailReceiver(UserMailFacts userAccount) { this.currentUser = userAccount; }
public void setCurrentUser(UserMailFacts currentUser) { this.currentUser = currentUser; }