private bool ShowSaveDialog() { using (var dialog = new SaveFileDialog()) { dialog.Filter = FileTypeHelper.GetAllFilters(); if (Template != null) { dialog.FilterIndex = FileTypeHelper.GetFilterIndex(GetExtensionByLanguage(Template.Syntax)); } else if (!string.IsNullOrEmpty(FileName)) { var info1 = new FileInfo(FileName); dialog.InitialDirectory = info1.DirectoryName; dialog.FilterIndex = FileTypeHelper.GetFilterIndex(info1.Extension); } if (dialog.ShowDialog() != DialogResult.OK) { return(false); } FileName = dialog.FileName; return(true); } }
private void mnuOpen_Click(object sender, EventArgs e) { using (var dialog = new OpenFileDialog()) { dialog.Filter = FileTypeHelper.GetAllFilters(); if (dialog.ShowDialog() == DialogResult.OK) { OpenFileName(dialog.FileName); } } }