public bool LoadConfig() { try { using (Stream stream = new FileStream(fileName, FileMode.Open)) { // Deserialize SioData IFormatter formatter = new SoapFormatter(); ReaderConfig sData = (ReaderConfig)formatter.Deserialize(stream); oData = sData; } } catch { return false; } return true; }
private void initConfigInfo() { //string logname = DateTime.Now.ToFileTimeUtc().ToString() + ".log"; logFile = log4net.LogManager.GetLogger("logdebug"); HelperConfigSerialize helper = new HelperConfigSerialize(conf); if (File.Exists(helper.fileName)) { if (helper.LoadConfig()) { writeLog("Load config file ok"); } else { helper.SaveConfig(); writeLog("Load config file fail, use default config"); } conf = helper.oData; } else { helper.SaveConfig(); } //test //CYMessageBox.Show("Hello,world"); //startRealInv(); }
public HelperConfigSerialize(ReaderConfig data) { oData = data; }