private bool SaveConfig() { FileStream fs = new FileStream("cadm.json", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(fs); try { CadmConfig cc = new CadmConfig(); cc.cvi_config = this.cvi_config.Text; cc.cvi_net = this.cvi_net.Text; cc.odoo = this.odoo.Text; cc.cvi_config_args = this.cvi_config_args.Text; cc.cvi_net_args = this.cvi_net_args.Text; cc.odoo_args = this.odoo_args.Text; string configs = JsonConvert.SerializeObject(cc); sw.Write(configs); } catch (Exception e) { return(false); } finally { sw.Close(); fs.Close(); } return(true); }
private void LoadConfig() { FileStream fs = new FileStream("cadm.json", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamReader sr = new StreamReader(fs); string configs = sr.ReadToEnd(); if (configs != "") { CadmConfig cc = JsonConvert.DeserializeObject <CadmConfig>(configs); _cvi_config = cc.cvi_config; _cvi_config_args = cc.cvi_config_args; _cvi_net = cc.cvi_net; _cvi_net_args = cc.cvi_net_args; _odoo = cc.odoo; _odoo_args = cc.odoo_args; } }