public static void getConfig() { LogFile lf = new LogFile(); // Program.ConfigFilePath = Environment.CurrentDirectory + "\\config.txt"; if (!File.Exists(Program.ConfigFilePath)) { Program.ConfigFileReadError = "配置文件不存在"; } else { string[] configStr = File.ReadAllLines(Program.ConfigFilePath, Encoding.GetEncoding("GB2312")); foreach (string tmpstr in configStr) { if (tmpstr.StartsWith("DataBasePath=")) { Program.ServerPath = getAttr(tmpstr); } else if (tmpstr.StartsWith("DataBasePort=")) { Program.ServerPort = getAttr(tmpstr); } else if (tmpstr.StartsWith("DataBaseUser="******"DateBasePWD=")) { Program.Pwd = getAttr(tmpstr); } else if (tmpstr.StartsWith("DataBaseName=")) { Program.DBName = getAttr(tmpstr); } else if (tmpstr.StartsWith("LogFilePath=")) { Program.LogFilePath = getAttr(tmpstr); } else if (tmpstr.StartsWith("XLSSHSToDGVCOL=")) { Program.keyValueStr = getAttr(tmpstr); } else if (tmpstr.StartsWith("XLSColsCount=")) { Int16 parseR = 0; if (Int16.TryParse(getAttr(tmpstr), out parseR)) { Program.XLSColsCount = parseR; } else { lf.write("XLSColsCount为空或者不为Int16整数"); } } else if (getAttr(tmpstr) == "false") { Program.WriteLogFile = false; } } } }