void 账户ToolStripMenuItemClick(object sender, EventArgs e) { string Current; Current = Directory.GetCurrentDirectory();//获取当前根目录 iniFile ini=new iniFile(Current+"/config.ini"); ArrayList list=ini.ReadSections(); if(list.Count==0) { frmAccount firstAccount=new frmAccount(); firstAccount.firstAccount="yes"; firstAccount.Show(); } else { frmAccount firstAccount=new frmAccount(); firstAccount.firstAccount="no"; firstAccount.Show(); } // string stemp=ini.ReadValue("Account","AccountName"); // if(string.IsNullOrEmpty(stemp)) // { // frmAccount firstAccount=new frmAccount(); // firstAccount.firstAccount="yes"; // firstAccount.Show(); //// addAccount.panel1.Visible=false; // //// frmAccount firstAccount=new frmAccount(); //// firstAccount.Show(); //// firstAccount. //// firstAccount.paa //// addAccount.Show(); //// addAccount.panel1.Visible=false; //// addAccount.label6.Visible=true; //// addAccount.txtAccountName.Visible=true; // } // else // { // frmAccount firstAccount=new frmAccount(); //// firstAccount.firstAccount="yes"; // firstAccount.Show(); // } }
public void WriteAccount() { //Account.ini : //AccountName; //POP3 //SMTP //username //password //port string AccountName=txtAccountName.Text.Trim(); if(!string.IsNullOrEmpty(AccountName)) { string Current; Current = Directory.GetCurrentDirectory();//获取当前根目录 // 写入ini iniFile ini=new iniFile(Current+"/config.ini"); ini.WriteValue(AccountName,"AccountName",AccountName); ini.WriteValue(AccountName,"POP3",txtPOP3.Text.Trim()); ini.WriteValue(AccountName,"SMTP",txtSMTP.Text.Trim()); ini.WriteValue(AccountName,"username",txtUsername.Text.Trim()); ini.WriteValue(AccountName,"password",txtPassword.Text.Trim()); ini.WriteValue(AccountName,"port",txtPort.Text.Trim()); } }
public void LoadIniFile() { string Current; Current = Directory.GetCurrentDirectory();//获取当前根目录 // 写入ini iniFile ini=new iniFile(Current+"/config.ini"); // ini.WriteValue("Setting","key1","hello word!"); // ini.WriteValue("Setting","key2","hello ini!"); // ini.WriteValue("SettingImg", "Path", "IMG.Path"); // 读取ini // string stemp = ini.ReadValue("Setting","key2"); // lbAccount.Items.Add(stemp); ArrayList list=ini.ReadSections(); foreach(object o in list) { lbAccount.Items.Add(o.ToString()); } if(lbAccount.Items.Count!=0) { lbAccount.SelectedIndex=0; } }
public void ReadAccount() { lbAccount.Refresh(); string Current; Current = Directory.GetCurrentDirectory();//获取当前根目录 string AccountName=lbAccount.SelectedItem.ToString(); iniFile ini=new iniFile(Current+"/config.ini"); txtAccountName.Text=ini.ReadValue(AccountName,"AccountName"); txtPOP3.Text=ini.ReadValue(AccountName,"POP3"); txtSMTP.Text=ini.ReadValue(AccountName,"SMTP"); txtUsername.Text=ini.ReadValue(AccountName,"username"); txtPassword.Text=ini.ReadValue(AccountName,"password"); txtPort.Text=ini.ReadValue(AccountName,"port"); }