/// <summary> /// 读取配置文件 /// </summary> /// <returns>返回是否成功</returns> public static bool readfromfile() { try { string path = AppDomain.CurrentDomain.BaseDirectory; using (Stream fs = new FileStream(path + "usr.cfg", FileMode.OpenOrCreate)) { BinaryFormatter formatter = new BinaryFormatter(); conf = (ConfigInfoData)formatter.Deserialize(fs); } } catch { } return true; }
/// <summary> /// 读取配置文件 /// </summary> /// <returns>返回是否成功</returns> public static bool readfromfile() { try { string path = AppDomain.CurrentDomain.BaseDirectory; using (Stream fs = new FileStream(path + "usr.cfg", FileMode.OpenOrCreate)) { BinaryFormatter formatter = new BinaryFormatter(); conf = (ConfigInfoData)formatter.Deserialize(fs); } } catch { } return(true); }
/// <summary> /// 读取配置文件 /// </summary> /// <returns>返回是否成功</returns> public static bool readfromfile(string username) { try { string path = AppDomain.CurrentDomain.BaseDirectory + "data\\" + username + "\\"; using (Stream fs = new FileStream(path + "usr.cfg", FileMode.OpenOrCreate)) { var formatter = new BinaryFormatter(); conf = (ConfigInfoData)formatter.Deserialize(fs); } //using (Stream fs = new FileStream(path + "usrList.cfg", FileMode.OpenOrCreate)) //{ // BinaryFormatter formatter = new BinaryFormatter(); // usrConfig = (Hashtable)formatter.Deserialize(fs); //} } catch { } return(true); }