using System.IO; namespace System.Windows.Forms { public abstract class FileDialog : IDisposable { protected internal Microsoft.Win32.FileDialog dialog; public string Title { get => dialog.Title; set => dialog.Title = value; } public string FileName { get => dialog.FileName; set => dialog.FileName = value; } public string Filter { get => dialog.Filter; set => dialog.Filter = value; } public int FilterIndex { get => dialog.FilterIndex; set => dialog.FilterIndex = value; } public string DefaultExt { get => dialog.DefaultExt; set => dialog.DefaultExt = value; } public string InitialDirectory { get => dialog.InitialDirectory; set { if (!string.IsNullOrEmpty(value)) { try { dialog.InitialDirectory = Path.GetFullPath(value); } catch { dialog.InitialDirectory = ""; } } else { dialog.InitialDirectory = value; } } } public bool CheckFileExists { get => dialog.CheckFileExists; set => dialog.CheckFileExists = value; } public bool CheckPathExists { get => dialog.CheckPathExists; set => dialog.CheckPathExists = value; } public void Dispose() { } public DialogResult ShowDialog() { return dialog.ShowDialog() == true ? DialogResult.OK : DialogResult.Cancel; } } }