Beispiel #1
0
 private void LoadConfiguration()
 {
     try
     {
         string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
         if (!File.Exists(filePath))
         {
             //File.Create(filePath);
             using (StreamWriter sw = new StreamWriter(filePath))
             {
                 sw.WriteLine("[Settings]");
                 sw.WriteLine("LocalIP=");
                 sw.WriteLine("UserName="******"ServerIP=");
                 sw.WriteLine("ServerPort=");
             }
         }
         AccessIni accessIni = new AccessIni();
         localIP  = accessIni.ReadIni("Settings", "LocalIP", "", filePath);
         userName = accessIni.ReadIni("Settings", "UserName", "", filePath);
         serverIP = accessIni.ReadIni("Settings", "ServerIP", "", filePath);
         int.TryParse(accessIni.ReadIni("Settings", "ServerPort", "0", filePath), out serverPort);
         if (!ValidData(localIP, userName, serverIP, serverPort.ToString()))
         {
             MessageBox.Show("文电管理尚未正确配置数据,请前往“设置”菜单进行设置!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #2
0
 private void SettingForm_Load(object sender, EventArgs e)
 {
     try
     {
         filePath               = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
         accessIni              = new AccessIni();
         localIP                = accessIni.ReadIni("Settings", "LocalIP", "", filePath);
         userName               = accessIni.ReadIni("Settings", "UserName", "", filePath);
         serverIP               = accessIni.ReadIni("Settings", "ServerIP", "", filePath);
         serverPort             = int.Parse(accessIni.ReadIni("Settings", "ServerPort", "0", filePath));
         textBoxX_LocalIP.Text  = localIP;
         textBoxX_UserName.Text = userName;
         textBoxX_ServerIP.Text = serverIP;
         textBoxX_Port.Text     = serverPort.ToString();
     }
     catch
     {
     }
 }