0

如何在 .NET 中获得完全限定的 MS Explorer 路径?

该路径将用于使用一些命令行参数启动 MS Explorer 的新实例。

4

3 回答 3

1

Windows 资源管理器始终位于路径中,因此只需使用命令行参数调用 explorer.exe 就足够了。

这同样适用于 Internet Explorer,其文件名为 iexplore.exe。

于 2009-07-29T11:07:10.270 回答
0

正如@devio所说,您实际上不需要在路径中指定它,但为了完整起见,您可以使用以下Environment.ExpandEnvironmentVariables方法:

string path = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\Explorer.exe");
于 2009-07-29T11:22:02.467 回答
0

谢谢!

任何有兴趣的人的完整代码片段是:

    // Launch MS Explorer with the correct log file selected.

    //string pathToExplorer = System.IO.Path.Combine( Environment.ExpandEnvironmentVariables("%WinDir%"),
    //                                                "explorer.exe");

    string pathToExplorer = "explorer.exe";

    string pathToLogFile = Process.GetCurrentProcess().MainModule.FileName + ".log";

    string arguments = String.Format(   CultureInfo.InvariantCulture,
                                        "/select, \"{0}\"",
                                        pathToLogFile);

    // C:\Windows\explorer.exe /select, "C:\projects\trunk\bin\MyCompany.App.StackTester.exe.log"

    Process.Start(  pathToExplorer,
                    arguments);
于 2009-07-29T11:42:11.060 回答