本文介绍了FolderbrowserDailog单击取消然后发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我们点击btnfolderdailog然后选择文件然后点击Ok然后它的井。

如果我们点击取消按钮然后发生错误:-ArgumentException was未处理



路径不合法。









Hi,
If we click btnfolderdailog then select the file and click "Ok" then its well.
If we click cancel button then occurred Error:-ArgumentException was Unhandled

The path is not of a legal form.




folderBrowserDialog1.ShowDialog();

            totalfolderfileCount = System.IO.Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*").Length;
            string[] array = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.bdf*");
            txtInputPath.Text = folderBrowserDialog1.SelectedPath;

推荐答案

if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) {
    totalfolderfileCount = System.IO.Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*").Length;
            string[] array = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.bdf*");
            txtInputPath.Text = folderBrowserDialog1.SelectedPath;

}







如果这有帮助,请花时间接受解决方案,以便其他人可以找到它。谢谢。




If this helps, please take time to accept the solution so that others may find it. Thank you.


这篇关于FolderbrowserDailog单击取消然后发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 12:59