c# 选中文件夹,选中文件

admin 2021-05-18 22:46:18 392浏览 0评论
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择文件路径";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
               string savePath = dialog.SelectedPath;
                //赋值给输入框
                this.textBox1.Text = savePath;
            }



选中文件

OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = true;//该值确定是否可以选择多个文件
dialog.Title = "请选择文件夹";
dialog.Filter = "所有文件(*.*)|*.*";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
    string file = dialog.FileName;
}


详细描述: https://www.cnblogs.com/liuqifeng/p/9149125.html

0条评论