When I run this code I get a Win32Exception thrown whenever the dialog closes. It doesn't seem to be a problem, and if I just catch it everything seems to work. Do you happen to know why that might be thrown?
–
Scott WisniewskiJan 17 '09 at 3:37

Seems to work fine but I can't see any point to it myself, calling with 0 arguments still shows the 'same' modal dialog.
–
JohnSep 9 '11 at 22:42

1

Worked beautifully for me, with no exceptions so far (.Net 3.5). Had to add a using statement for System.Windows.Interop. Easy to extend the solution for use with System.Windows.Forms.OpenFileDialog. Fellow readers - don't forget to check the DialogResult to make sure the user didn't click on the Cancel button.
–
sfuquaOct 14 '11 at 22:33

The advantage of passing an owner handle is that the FolderBrowserDialog will not be modal to that window. This prevents the user from interacting with your main application window while the dialog is active.