NullReferenceException from FolderBrowserDialog

  • Thread starter Thread starter ondrej421
  • Start date Start date
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!
 
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
 
Back
Top