Showing file in Windows Explorer

邮差的信 提交于 2019-12-07 00:42:15

问题


My favorite IDE Wing IDE has a command for showing the active file in Explorer. This means that when you launch the command, it opens an explorer window on the folder that the file is in, and then selects the file.

The problem is, that if the window is already open, it fails to select the file. It activates the window, but the file doesn't get selected. That's annoying. I want the file to always be selected

I spoke to one of the developers and he said that they're using 'explorer /select,%s' % filename to show the file, and that the above annoyance might be a quirk of that command.

Does anyone have an idea how to avoid this behavior?

(The solution needs to work in Windows 2000, XP, 2003 Server, Vista, and Windows 7.)


回答1:


As per https://support.microsoft.com/en-us/kb/152457, which states "switches can be combined", what about:

explorer /n,/select,c:\path\to\file.ext

/n should force a new window.




回答2:


I dont know if one exists, but if you create utility which would be implement such solution(C++) it would work as you expected:

void OpenFileInExplorer(LPCTSTR filename)
{
    ITEMIDLIST *pidl = ILCreateFromPath(filename);
    if(pidl) 
    {
        SHOpenFolderAndSelectItems(pidl,0,0,0);
        ILFree(pidl);
    }
}


来源:https://stackoverflow.com/questions/13702222/showing-file-in-windows-explorer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!