I have to edit an add-in that was written in visual studio in the vb.net language. What I need is a way to get a list of all the currently selected files from the active windows explorer window so that I can pass this to another function within the program. I'm not super experienced in visual studio (most of my experience has been in VBA which uses VB 6.0) so I'm looking for some advice before I spend too much time going down the wrong path.
I was thinking of using the Windows Shell object. I've found some examples written in C++ and I've spent some time reading through the MSDN, but before I invest a ton of time in this I wanted to reach out here to more experienced VB.Net/VS users. I know .Net has a lot of built in options for dealing with file/folder objects under the system.io namespace, but I haven't found anything yet that would allow me to see what are the currently selected items in an explorer window.
I'm just wondering if there is something native within .Net that would do what I need?
If not, is using the Windows Shell object the best way to go?
This is just a minor revision of this answer. Rather than work off the focused item as the linked answer does, get the selected items from the
ShellFolderView
.System.IO
wont do you much good because the File/Folder related classes have to do with the file system - the files have no idea if Explorer has them selected.First, add reference to
Microsoft Shell Controls and Automation
andMicrosoft Internet Controls
(see the above link).Usage (in a button click):
Modified to work on either
IShellFolderViewDual
orShellFolderView