The problem we need to solve is this: programmers are not allowed to inherit file dialog boxes in VB.NET 2005 and there are two kinds: open and save.
I once made an encryption program that worked like a safe for personal data. In my program, there were buttons named import and export, and I thought it was ugly to use dialogs with buttons whose captions were save, open. Sometimes we need to change button captions in certain situations. This project is good for those who want to design a customized file dialog box. It contains an implementation of three "tree view" file dialog boxes. The first one uses the Microsoft files-folders tools. The second one is a simple dialog that will show a file description of any file you select. The third one is a rich dialog with a progress bar, movable menu, status bar, and multiple view choices: details ,list, large icons ...
A basic knowledge of the language and tree-list view controls.
Using the code
Import all the code files of the dialog you like in your project and just handle the files in the code of the "Proceed" button instead of showing the messagebox. I will not explain everything here, but only the headlines: when you load the form, the program will use
Directory.GetLogicalDrives to get all the drives in your computer and will add them in the tree view control. An image list is needed here to set the small icons for the list of drives. Now we will need a procedure to get a level of folders to handle the click on any node (after the select event). This procedure will take the name of the node (the drive or the folder) and will display the children of this node according to the names of the nested folders of the drive or folder, and will display the files in the list view control. Two image lists are needed here because of the two views (large icons, small icons), and you must bind them to the list control. Here are the main procedures:
Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode)
Dim foldername As String
Dim filename As String
On Error GoTo eee
For Each foldername In Directory.GetDirectories(path)
On Error GoTo eee
Dim jj = foldername.LastIndexOf("\")
Dim jj1 = foldername.Length - jj
Dim foldr = foldername.Substring((jj + 1), (jj1 - 1))
Sub displayfiles(ByVal path As String)
Points of Interest
If you shell the dialog after you add a USB flash disk or a new network place, they will not appear, so you need to plan to add a refresh button.