public void SaveStoryFile() { try { var sfd = new SaveFileDialog(); sfd.Filter = STORY_FILE_DIALOG_FILTER; sfd.InitialDirectory = LastFileDir; sfd.FileName = $"{_story.UrlID}.{STORY_FILE_DIALOG_SUFFIX}"; sfd.ValidateNames = true; sfd.OverwritePrompt = true; if (sfd.ShowDialog() == DialogResult.OK) { StoryFileHelperJson.SaveInteractiveStory(sfd.FileName, _story); _story.HasChanged = false; LastFileDir = Path.GetDirectoryName(sfd.FileName); UpdateStatusMessage("Story saved to file"); log.Info("Story saved to file"); } } catch (Exception ex) { UpdateStatusMessage("Error saving story to file"); log.Error("Error saving story to file", ex); } }
private void OpenStoryFromFile() { try { WInteractiveStory story; var ofd = new OpenFileDialog(); ofd.Filter = STORY_FILE_DIALOG_FILTER; ofd.InitialDirectory = LastFileDir; ofd.ValidateNames = true; if (ofd.ShowDialog() == DialogResult.OK) { log.Info("Opening story from file"); story = StoryFileHelperJson.DeserializeInteractiveStory(File.ReadAllText(ofd.FileName)); LastFileDir = Path.GetDirectoryName(ofd.FileName); _OpenStory(story); UpdateStatusMessage("Story opened from file"); } } catch (Exception ex) { log.Error("An error occured when trying open the story from a file.", ex); } }