C # Open the specified directory and locate the file

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:

 Copy Code
 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); }
 Copy Code

 

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:\


  • two
    give the thumbs-up
  • step on
  • thirty
    Collection
    Think it's good? One click collection
  • six
    comment

Is "relevant recommendation" helpful to you?

  • Very unhelpful
  • No help
  • commonly
  • to be helpful to
  • Very helpful
Submit
Comments six
Add Red Packet

Please fill in the red envelope greeting or title

individual

The minimum number of red packets is 10

element

The minimum amount of red packet is 5 yuan

Current balance three point four three element Go to recharge>
To be paid: ten element
Achieve 100 million technicians!
After receiving, you will automatically become a fan of the blogger and the red envelope owner rule
hope_wisdom
Red packet sent
Paid in element
Payment with balance
Click to retrieve
Scan code for payment
Wallet balance zero

Deduction description:

1. The balance is the virtual currency of wallet recharge, and the payment amount is deducted at a ratio of 1:1.
2. The balance cannot be directly purchased and downloaded, but VIP, paid columns and courses can be purchased.

Balance recharge