Open file location

前端 未结 2 1065
猫巷女王i
猫巷女王i 2021-02-07 12:36

When searching a file in Windows Explorer and right-click a file from the search results; there is an option: \"Open file location\". I want to implement the same in my C# WinFo

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 12:52

    This is how I do it in my code. This will open the file directory in explorer and select the specified file just the way windows explorer does it.

    if (File.Exists(path))
    {
        Process.Start(new ProcessStartInfo("explorer.exe", " /select, " + path);
    }
    

提交回复
热议问题