public static bool SaveAs(Window window, DesktopDocument document) { string filename = FileSupport.MakeValidFileName(document.Title); SaveFileDialog fd = new SaveFileDialog { InitialDirectory = DesktopApp.Instance.Settings.DocumentFolder, FileName = filename, Filter = BaseDocument.GetFilterString(true, document.DocType), FilterIndex = 0, }; if (fd.ShowDialog(window) == true) { string path = fd.FileName; if (File.Exists(path) && path != document.Path) { if (MessageBox.Show(window, "File '" + path + "' exists. Overwrite?", "Save Document", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation) == MessageBoxResult.OK) { return(document.Save(path, true)); } return(false); } else if (path == document.Path) { return(document.Save()); } else { return(document.Save(path, false)); } } return(false); }