I would like to code a function to which you can pass a file path, for example:
C:\\FOLDER\\SUBFOLDER\\FILE.TXT
and it would open Windows E
The supported method since Windows XP (i.e. not supported on Windows 2000 or earlier) is SHOpenFolderAndSelectItems:
void OpenFolderAndSelectItem(String filename)
{
// Parse the full filename into a pidl
PIDLIST_ABSOLUTE pidl;
SFGAO flags;
SHParseDisplayName(filename, null, out pidl, 0, out flags);
try
{
// Open Explorer and select the thing
SHOpenFolderAndSelectItems(pidl, 0, null, 0);
}
finally
{
// Use the task allocator to free to returned pidl
CoTaskMemFree(pidl);
}
}