⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filedialog.cs

📁 wince open file dialog source code
💻 CS
字号:
#region Using 指令

using System;
using System.Windows.Forms;

#endregion

namespace ffDialog
{
    //查看方式
    /// <summary> 
    /// 文件查看模式,包括列表模式和详细信息模式
    /// </summary>
    public enum ViewType { List, Detial };//目标Item类型:文件 or 文件夹

    //FFDialog模式:打开文件 OR 保存文件
    public enum DialogModType { OpenFile, SaveFile };

    /// <summary>
    /// FileDialog 的摘要说明。
    /// </summary>
    public class FileDialog
    {
        string _filename;
        //获得文件名
        /// <summary> 
        /// 反馈被选中的文件名
        /// </summary>
        public string FileName
        {
            get
            {
                return _filename + "";
            }
        }

        public FileDialog()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }

        /// <summary>
        /// 调用打开文件对话框,返回用户是否完成成功操作.用户选择文件地址将通过FileName属性返回.
        /// </summary>
        public bool ShowOpenFileDialog(string DefalutPach, ViewType DefaultViewType, string Exts)
        {
            DialogForm ShowF = new DialogForm();
            ShowF.Text = "打开文件";
            ShowF.DialogMod = DialogModType.OpenFile;
            ShowF.DefaultDir = DefalutPach;
            ShowF.DefaultViewType = DefaultViewType;
            ShowF.Filetype = Exts;

            if (ShowF.ShowDialog() == DialogResult.Yes)
            {
                _filename = ShowF.FileName;

                ShowF.Dispose();
                ShowF = null;

                return true;
            }
            else
            {
                _filename = "";

                ShowF.Dispose();
                ShowF = null;

                return false;
            }
        }

        /// <summary>
        /// 调用保存文件对话框,返回用户是否完成成功操作.用户选择文件地址将通过FileName属性返回.
        /// </summary>
        public bool ShowSaveFileDialog(string DefalutPach, ViewType DefaultViewType, string Exts)
        {
            DialogForm ShowF = new DialogForm();
            ShowF.Text = "保存文件";
            ShowF.DialogMod = DialogModType.SaveFile;
            ShowF.DefaultDir = DefalutPach;
            ShowF.DefaultViewType = DefaultViewType;
            ShowF.Filetype = Exts;
            
            if (ShowF.ShowDialog() == DialogResult.Yes)
            {
                _filename = ShowF.FileName;

                ShowF.Dispose();
                ShowF = null;

                return true;
            }
            else
            {
                _filename = "";

                ShowF.Dispose();
                ShowF = null;

                return false;
            }
        }

        //施放内存
        public void Dispose()
        {
            //
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -