123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 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;
- }
- }
- }
|