NullReferenceException from FolderBrowserDialog

O

ondrej421

Hi there,

My application, which uses the FolderBrowserDialog, sometimes throws a
NullReferenceException with the following call stack when calling
FolderBrowserDialog.ShowDialog():

at
System.Windows.Forms.UnsafeNativeMethods.Shell32.SHBrowseForFolder(BROWSEINFO
lpbi)
at System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
...

Any ideas what could be causing this?

Thank you!
 
S

Scott M.

It is most likely caused when no file is selected and the OK button is
pressed or when the cancel button is pressed. You must code for these two
possibilities.

-Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top