server_cfg.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 IP;
  10. public string Port;
  11. public string User;
  12. public string PassWd;
  13. public string RootPath;
  14. public string Local;
  15. public void MyServerOption(string fileName)
  16. {
  17. //加载配置文件
  18. StreamReader objReader = new StreamReader(fileName);
  19. string sLine = "";
  20. List<string> array_CfgInfo = new List<string>();
  21. while (sLine != null)
  22. {
  23. sLine = objReader.ReadLine();
  24. array_CfgInfo.Add(sLine);
  25. }
  26. objReader.Close();
  27. //设定服务器配置
  28. IP = array_CfgInfo[0].Substring(array_CfgInfo[0].LastIndexOf("=") + 1);
  29. Port = array_CfgInfo[1].Substring(array_CfgInfo[1].LastIndexOf("=") + 1);
  30. User = array_CfgInfo[2].Substring(array_CfgInfo[2].LastIndexOf("=") + 1);
  31. PassWd = array_CfgInfo[3].Substring(array_CfgInfo[3].LastIndexOf("=") + 1);
  32. RootPath = array_CfgInfo[4].Substring(array_CfgInfo[4].LastIndexOf("=") + 1);
  33. Local = array_CfgInfo[5].Substring(array_CfgInfo[5].LastIndexOf("=") + 1);
  34. }
  35. }
  36. }