Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.




SQL
folderBrowserDialog1.ShowDialog();

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

1 solution

You call ShowDialog and then use folderBrowserDialog1.SelectedPath property.

You didn't handle the canceling - you're just going as if everything is fine. Every time you call ShowDialog on anything, you should process dialog result and work depending on that result.


C#
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.
 
Share this answer
 
Comments
Ram jha 7-Oct-14 5:07am    
Thanks Sinisa.
Sinisa Hajnal 7-Oct-14 5:48am    
No problem. Why vote of 2?
Ram jha 7-Oct-14 7:59am    
Sorry.........Now update
Sinisa Hajnal 7-Oct-14 8:05am    
Sorry? What update?
Ah, I get it, you tried to update it. I think you have to contact CodeProject support

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900