void LoadPaths() { string confPath = System.Environment.CurrentDirectory + "Config.txt"; if (!File.Exists(confPath)) { return; } string jsonContent = string.Empty; using (StreamReader sr = new StreamReader(confPath)) { jsonContent = sr.ReadToEnd(); } if (jsonContent != string.Empty) { PathsConfiguration ps = LitJson.JsonMapper.ToObject <PathsConfiguration>(jsonContent); pathExcel1.Text = ps.excel; pathFileSave1.Text = ps.saveFile; ignoreLines.Value = ps.removedHead < ignoreLines.Maximum && ps.removedHead >= ignoreLines.Minimum ? ps.removedHead : ignoreLines.Minimum; sheet1.Value = ps.sheets >= sheet1.Minimum && ps.sheets <= sheet1.Maximum ? ps.sheets : sheet1.Minimum; isUseCompress.Checked = ps.isCompress; unCompressSrcPath.Text = ps.unCompressSrcPath; unCompressSavePath.Text = ps.unCompressSavePath; } }
void RememberPaths() { PathsConfiguration ps = new PathsConfiguration(); ps.excel = pathExcel1.Text; ps.saveFile = pathFileSave1.Text; ps.removedHead = (int)ignoreLines.Value; ps.sheets = (int)sheet1.Value; ps.isCompress = isUseCompress.Checked; ps.unCompressSrcPath = unCompressSrcPath.Text; ps.unCompressSavePath = unCompressSavePath.Text; string confPath = System.Environment.CurrentDirectory + "Config.txt"; using (StreamWriter sw = new StreamWriter(confPath, false)) { sw.Write(LitJson.JsonMapper.ToJson(ps)); } }