/// <summary> /// 将连接字符串保存到INI文件中。用户名密码会自动加密。 /// </summary> /// <param name="iniPath"></param> /// <returns></returns> public bool SaveToIni(string iniPath) { try { IniAccess.CreateFile(iniPath); IniAccess ia = new IniAccess(iniPath); ia.Section = "System"; ia.WriteValue("DataSource", DataSource); ia.WriteValue("InitialCatalog", InitialCatalog); ia.WriteValue("UserID", DESCrypto.Encrypt(UserID)); ia.WriteValue("Password", DESCrypto.Encrypt(Password)); ia.WriteValue("TrustedConnection", TrustedConnection.ToString()); } catch (Exception e1) { Console.WriteLine(e1.Message); return(false); } return(true); }
/// <summary> /// 保存至Ini文件。 /// </summary> /// <param name="ia"></param> public void SaveToIni(IniAccess ia) { if (NeedSave) { string s = GetValue(); if (NeedCrypto) { s = DESCrypto.Encrypt(s); } ia.WriteValue(FullName, s); } }
private void btnOK_Click(object sender, EventArgs e) { ia.WriteValue("ClosePassword", txtPassword.Text); Close(); }