void BtnClicked(object sender, EventArgs e) { if (FileSelectionMode == FileSelectionMode.Open) { dialog = new OpenFileDialog(); } else { dialog = new SaveFileDialog(); } try { foreach (var f in filters) { dialog.Filters.Add(f); } if (!string.IsNullOrEmpty(currentFolder)) { dialog.CurrentFolder = currentFolder; } if (activeFilter != null) { dialog.ActiveFilter = activeFilter; } if (!string.IsNullOrEmpty(title)) { dialog.Title = title; } if (dialog.Run(ParentWindow)) { FileName = dialog.FileName; currentFolder = dialog.CurrentFolder; // do not update the active filter, since we don't want the // picker to propagate filter changes back to the selector. //activeFilter = dialog.ActiveFilter; } } finally { dialog.Dispose(); dialog = null; } }
void BtnClicked(object sender, EventArgs e) { if (FileSelectionMode == FileSelectionMode.Open) { dialog = new OpenFileDialog(); } else { dialog = new SaveFileDialog(); } try { foreach (var f in filters) { dialog.Filters.Add(f); } if (!string.IsNullOrEmpty(currentFolder)) { dialog.CurrentFolder = currentFolder; } if (activeFilter != null) { dialog.ActiveFilter = activeFilter; } if (!string.IsNullOrEmpty(title)) { dialog.Title = title; } if (dialog.Run(ParentWindow)) { FileName = dialog.FileName; } } finally { currentFolder = dialog.CurrentFolder; activeFilter = dialog.ActiveFilter; dialog.Dispose(); dialog = null; } }
void BtnClicked(object sender, EventArgs e) { if (FileSelectionMode == FileSelectionMode.Open) dialog = new OpenFileDialog (); else dialog = new SaveFileDialog (); try { foreach (var f in filters) dialog.Filters.Add (f); if (!string.IsNullOrEmpty (currentFolder)) dialog.CurrentFolder = currentFolder; if (activeFilter != null) dialog.ActiveFilter = activeFilter; if (!string.IsNullOrEmpty (title)) dialog.Title = title; if (dialog.Run (ParentWindow)) FileName = dialog.FileName; } finally { currentFolder = dialog.CurrentFolder; activeFilter = dialog.ActiveFilter; dialog.Dispose (); dialog = null; } }