private void button5_Click(object sender, EventArgs e) //保存脚本 { if (dataGridView1.Rows[0].Cells[0].Value.ToString().Trim().Length == 0) { return; } else { TextFileDialog fileDialog = new TextFileDialog(); Parse parse = new Parse(); string script = parse.ParseToScript(parse.GetArray(dataGridView1)); if (!Directory.Exists(Properties.Resources.ScriptsDirectory)) { Directory.CreateDirectory(Properties.Resources.ScriptsDirectory); } string directory = AppDomain.CurrentDomain.BaseDirectory + Properties.Resources.ScriptsDirectory; fileDialog.SaveText(script, directory, ""); } }
private void button4_Click(object sender, EventArgs e) //读取脚本 { TextFileDialog fileDialog = new TextFileDialog(); Parse parse = new Parse(); string directory = AppDomain.CurrentDomain.BaseDirectory + Properties.Resources.ScriptsDirectory; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string script = fileDialog.ReadText(directory); if (script.Length == 0) { return; } ArrayList cmd = parse.ParseToArray(script, Table.COLUMN_COUNT); ClearDataGridView(dataGridView1); parse.SetArray(cmd, dataGridView1); }