private void saveXmlFile() { string xmlDir = Application.StartupPath + "\\xml\\"; if (Directory.Exists(xmlDir) == false) { Directory.CreateDirectory(xmlDir); } MySQLXmlFile xmlFile = new MySQLXmlFile(); xmlFile.dbip = tbx_dbip.Text; xmlFile.port = tbx_port.Text; xmlFile.user = tbx_user.Text; xmlFile.pwd = tbx_pwd.Text; xmlFile.schema = tbx_schema.Text; xmlFile.SavePath = tbx_SavePath.Text; string xmlString = JsonConvert.SerializeObject(xmlFile); StreamWriter streamWriter = File.CreateText(Application.StartupPath + "\\xml\\mysql.xml"); streamWriter.Write(xmlString); streamWriter.Flush(); streamWriter.Close(); }
private void Form_MySQL_Load(object sender, EventArgs e) { this.Icon = Resources.mysql; string xmlFilePath = Application.StartupPath + "\\xml\\mysql.xml"; if (File.Exists(xmlFilePath) == true) { StreamReader streamReader = File.OpenText(xmlFilePath); string getXmlString = streamReader.ReadToEnd(); MySQLXmlFile xmlFile = (MySQLXmlFile)JsonConvert.DeserializeObject(getXmlString, typeof(MySQLXmlFile)); if (xmlFile != null) { tbx_dbip.Text = xmlFile.dbip; tbx_port.Text = xmlFile.port; tbx_user.Text = xmlFile.user; tbx_pwd.Text = xmlFile.pwd; tbx_schema.Text = xmlFile.schema; tbx_SavePath.Text = xmlFile.SavePath; } streamReader.Close(); } tabControl2.SelectedTab = tp_selectBuilder; }