Exemple #1
0
 /// <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);
 }
Exemple #2
0
        /// <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);
            }
        }
Exemple #3
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     ia.WriteValue("ClosePassword", txtPassword.Text);
     Close();
 }