We want to prevent the user from doing anything except selecting a folder. We don’t want to allow him to delete files/folders, rename them, access the context menu, etc. But we can’t override anything since FolderBrowserDialog is sealed.
We googled around and found some solutions:
- Implement our own FolderBrowserDialog: Don’t have time for this, only acceptable as last resort
- This guy did it for an OpenFileDialog, might work but seems a little overkill
Anyone faced this problem and found an optimal solution for this? It must be .NET 4.0 compatible
In the end, we solved it implementing our own control. It was a lot simpler than we thought. In short, we just made a class inherit from System.Windows.Forms.Form, with a System.Windows.Forms.TreeView on the left and a System.Windows.Forms.ImageList on the right to show the current folder’s contents. Then we DllImport’ed SHGetFileInfo and ExtractIconEx from Shell32 in order to make the TreeView and ImageList’s icons look like Explorer’s, and voila!