server_cfg.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.IO;
  5. namespace MOTINOVA_Motor_Factory_Set
  6. {
  7. public class server_cfg
  8. {
  9. public string ServerName;
  10. public string IP;
  11. public string Port;
  12. public string User;
  13. public string PassWd;
  14. public string RootPath;
  15. public string Local;
  16. public void MyServerOption(string fileName)
  17. {
  18. //加载配置文件
  19. StreamReader objReader = new StreamReader(fileName);
  20. string sLine = "";
  21. List<string> array_CfgInfo = new List<string>();
  22. while (sLine != null)
  23. {
  24. sLine = objReader.ReadLine();
  25. array_CfgInfo.Add(sLine);
  26. }
  27. objReader.Close();
  28. //设定服务器配置
  29. ServerName = array_CfgInfo[0].Substring(array_CfgInfo[0].IndexOf("#") + 1);
  30. IP = array_CfgInfo[1].Substring(array_CfgInfo[1].LastIndexOf("=") + 1);
  31. Port = array_CfgInfo[2].Substring(array_CfgInfo[2].LastIndexOf("=") + 1);
  32. User = array_CfgInfo[3].Substring(array_CfgInfo[3].LastIndexOf("=") + 1);
  33. PassWd = array_CfgInfo[4].Substring(array_CfgInfo[4].LastIndexOf("=") + 1);
  34. RootPath = array_CfgInfo[5].Substring(array_CfgInfo[5].LastIndexOf("=") + 1);
  35. Local = array_CfgInfo[6].Substring(array_CfgInfo[6].LastIndexOf("=") + 1);
  36. }
  37. }
  38. }