如何让openFileDialog Filter只选择文件夹

如何让openFileDialog Filter只选择文件夹,第1张

OpenFileDialog

是用来敬谨进尺裤行文件选择的。

选择文件夹的话

FolderBrowserDialog

就可以了陵稿简。

用vs2012试了一下侍猛,没有出老迹桥现你提到的问题啊

     private void button1_Click(object sender, EventArgs e)

        {

            OpenFileDialog dialog = new OpenFileDialog()

            dialog.Filter = "所有文件|*.*"

            dialog.Multiselect = true

            dialog.SupportMultiDottedExtensions = true

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)

            {

                listBox1.Items.Clear()

                foreach (string s in 州答dialog.SafeFileNames)

                {

                    listBox1.Items.Add(s)

                }

            }

        }


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/12278888.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存