one
open a folder :
System.Diagnostics.Process.Start(FilePath);
open a folder A file in:
System.Diagnostics.Process.Start(FilePath+"/"+FileName);
open a folder And select a single file:
System.Diagnostics.Process.Start("Explorer", "/select,"+ FilePath+"\\"+FileName);
or
System.Diagnostics.Process.Start("Explorer.exe", "/select,"+ FilePath+"\\"+FileName);
Open the file with IE:
System.Diagnostics.Process.Start("Explorer",FilePath+"\\"+FileName);
or
System.Diagnostics.Process.Start("Explorer.exe",FilePath+"\\"+FileName);
Note: (explorer, explorer.exe,select, Case insensitive, "/select," where "/," cannot be missing, FilePath is the file path and does not contain the file name)
Extension prompt: Application can be used StartupPath gets the directory where the application is located.
two
C # implementation:
private void OpenFolderAndSelectFile(String fileFullName) { System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo( " Explorer.exe " ); psi.Arguments = " /e,/select, " + fileFullName; System.Diagnostics.Process.Start(psi); }
reference resources:
Usage of Windows Explorer parameters.
Explorer /n
This command opens an Explorer window with default settings. The content displayed is usually the root directory of the drive where Windows is installed.
Explorer /e
This command starts Windows Explorer using the default view.
Explorer /e,C:\Windows
This command starts Windows Explorer using the default view and focuses on C: Windows.
Explorer /root, C:\Windows\Cursors
This command starts Windows Explorer and focuses on C: Windows Cursors folder. This example uses C: Windows Cursors as the "root" directory of Windows Explorer.
Note: Please note the comma after the "/root" parameter in the command.
Explorer /select, C:\Windows\Cursors\banana.ani
This command starts Windows Explorer and selects the file "C: Windows Cursors banana. ani".
Note: Please note the comma after the "/select" parameter in the command.
Windows Explorer parameters can be combined in one command. The following example shows a combination of Windows Explorer command line parameters.
Explorer /root, \\server\share, select, Program.exe
This command starts Windows Explorer with the remote share as the "root" folder, and the Program.exe file will be selected.
Back to top
Change Windows Explorer default startup folder
To change the default startup folder for Windows Explorer:
Click Start, point to All Programs, point to Accessories, and then right-click Windows Explorer.
On the menu that appears, click Properties.
In the Target box, append the "/root" command line parameter to the "% SystemRoot% Explorer.exe" command and use the desired startup location. For example, if you want Windows Explorer to locate at the root of drive C after starting, edit the command as:
%SystemRoot%\Explorer.exe /root, C:\