public Save ( string Path, |
||
Path | string | |
JSON | ||
Format | System.Text.Format | |
Результат | void |
private void MenuFileSave_Click(object sender, EventArgs e) { if (rootObject.ChildObjects.Count == 0) { MessageBox.Show("There is no data to save. Add some data to the file and then try again."); return; } #region Figure out File Path string saveFile = null; if (!string.IsNullOrEmpty(SaveDialog.FileName)) { saveFile = SaveDialog.FileName; } else if (!string.IsNullOrEmpty(FileDialog.FileName)) { saveFile = FileDialog.FileName; } else { if (SaveDialog.ShowDialog() != DialogResult.OK) { return; } saveFile = SaveDialog.FileName; } #endregion #region Make Backup File if (MenuPrefBackup.Checked && File.Exists(saveFile)) { File.Copy(saveFile, saveFile + ".bak", true); } #endregion JSONFile jf = new JSONFile(saveFile); jf.Save(saveFile, rootObject, this.format); settings.LastFilePath = saveFile; this.Text = "JSONTools - " + settings.LastFilePath; hasChanged = false; }
private void MenuFileSaveAs_Click(object sender, EventArgs e) { if (SaveDialog.ShowDialog() != DialogResult.OK) { return; } JSONFile jf = new JSONFile(SaveDialog.FileName); jf.Save(SaveDialog.FileName, rootObject, this.format); settings.LastFilePath = SaveDialog.FileName; this.Text = "JSONTools - " + settings.LastFilePath; }