I need to get the path ... But it doesn't return the location of special folders like Computer, Recycle Bin, Network etc.
The immediate problem you're running into is that LocationURL
returns ""
if the window's location is not a physical directory. For "My Computer", "Recycle Bin", and "Network", this isn't surprising -- those are virtual folders; there isn't a path or URL that could point to them, because they're not locations on disk.
However, if you navigate to "Documents" (which does correspond to a directory on disk, even though it's also a special folder), LocationURL
still returns ""
. Here it could give you a path, but it chooses not to. This seems somewhat mean-spirited of it.
I found some documentation that says that ShellWindows returns InternetExplorer
objects. I couldn't find any docs for the ShellBrowserWindow
class you're using but InternetExplorer
appears to be similar or identical, so it's got some documentation you can refer to instead of just having to look at the property names in Intellisense.
The only other property that looks useful is LocationName
, which does return something even for virtual or special folders. However, it returns a string like "Documents" or "Libraries", which isn't something you could really make any use of programmatically (it'd be different in different locales, different Windows versions, etc.)
If all you need is something to show in a list, LocationName
would probably suffice. If you actually need the path, you're probably out of luck (though you would be anyway, because as noted, things like Computer, Recycle Bin, and Network don't have paths).