private bool ReadConfigFile() { if (File.Exists(ConfigFilename)) { Stream stream = null; try { stream = File.Open(ConfigFilename, FileMode.Open); var xmlSer = new XmlSerializer(typeof(LoginInfo)); GlobalInfo.LoginInfo = (LoginInfo)xmlSer.Deserialize(stream); ProxyProviderLoader.UseProvider = GlobalInfo.LoginInfo.ProviderType; if (GlobalInfo.LoginInfo.RememberLastLogin) { GlobalInfo.LoginInfo.LastPassword = Cryption.Decrypt(GlobalInfo.LoginInfo.LastPassword); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } finally { stream.Close(); } return(true); } return(false); }
public void WriteConfigFile() { if (!System.IO.Directory.Exists(ConfigDirectory)) { System.IO.Directory.CreateDirectory(ConfigDirectory); } TextWriter stream = new StreamWriter(ConfigFilename); var xmlSer = new XmlSerializer(typeof(LoginInfo)); GlobalInfo.LoginInfo.LastPassword = GlobalInfo.LoginInfo.RememberLastLogin ? Cryption.Encrypt(GlobalInfo.LoginInfo.LastPassword) : string.Empty; xmlSer.Serialize(stream, GlobalInfo.LoginInfo); if (GlobalInfo.LoginInfo.RememberLastLogin) { GlobalInfo.LoginInfo.LastPassword = Cryption.Decrypt(GlobalInfo.LoginInfo.LastPassword); } stream.Close(); }