2009-07-29 21 views

回答

1

Windows資源管理器始終位於Path中,因此只需使用命令行參數調用explorer.exe即可。

同樣適用於Internet Explorer,其文件名爲iexplore.exe。

0

正如所說的@devio,你並不需要,因爲它是在路徑來指定,但爲了完整起見,你可以使用Environment.ExpandEnvironmentVariables方法:

string path = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\Explorer.exe"); 
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); 
相關問題