Dear.Va 2020-04-09 09:33 采纳率: 0%
浏览 355

请问如何在winform中实现这种选择文件夹的效果?

在winform中直接调用FolderBrowserDialog弹出的是这样的窗口:
图片说明

但是在win10的一些应用中(如Defender),选择文件夹是这种高级的样式:
图片说明

请问这要怎么实现呢?是要调用什么dll吗?

  • 写回答

2条回答 默认 最新

  • 辣椒日จุ๊บ 2020-04-09 10:08
    关注

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace Selectfile
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Multiselect = false;//该值确定是否可以选择多个文件
            dialog.Title = "请选择电子文档excel";
            dialog.Filter = "所有文件(*.xlsx)|*.xlsx";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textBox1.Text = dialog.FileName;
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog P_File_Folder = new FolderBrowserDialog();
            if (P_File_Folder.ShowDialog() == DialogResult.OK)
            {
                textBox2.Text = P_File_Folder.SelectedPath;
            }
        }
    }
    

    }
    图片说明

    评论

报告相同问题?