public bool LoadConfig() { XmlSerializer s = new XmlSerializer(typeof(ThkEnvConfigs)); string fname = strCfgPath + strCfgFile; FileInfo fi = new FileInfo(fname); if (!fi.Exists) { TextWriter w = new StreamWriter(fname); s.Serialize(w, envconfigs); w.Close(); } else { TextReader r = new StreamReader(fname); envconfigs = (ThkEnvConfigs)s.Deserialize(r); r.Close(); } return(true); }
public ThkEnvCfgs() { strCfgFile = "ThkDevEnv.config"; string path = System.Environment.CurrentDirectory; Assembly myAssembly = Assembly.GetEntryAssembly(); if (myAssembly == null) { myAssembly = Assembly.GetExecutingAssembly(); } if (myAssembly != null) { path = myAssembly.Location; DirectoryInfo dr = new DirectoryInfo(path); path = dr.Parent.FullName; //当前目录的上一级目录 } strCfgPath = path + "\\"; envconfigs = new ThkEnvConfigs(); }