windows 用默认软件打开文档

时间:2021-11-26 05:40:44
 System.Diagnostics.Process.Start("Explorer.exe", string.Format("/e, \"{0}\" ", TargetFileName));

Windows Explorer can be invoked (called, started) with parameters to get a specific view.

Syntax

explorer [/n] [/e,] [/root,object,][[/select],sub-object,]

Strangely enough a final comma is required (at least in some cases – not known in which ones)!

Parameters

/n Opens a window in single-paned (My-computer) view for each selected item, even if the new window duplicated a window that is already open. This is the default view.
/e Uses Windows Explorer view, which is most similar to File Manager view (Windows 3.x).
/root,object Specifies the root level of the specified view. Default is to use the normal namespace root (desktop = my computer), whatever is specified for the root for the display.
/select If /select is used, the parent folder is opened and the specified object is selected.

Examples

Display (explorer mode) drive D only Explorer.exe /e, /root, d:\
Display (explorer mode) the start menu programs Explorer.exe /e, /root, "f:\Win_95\Start Menu\Programs"
Diplay (single paned view) the c:windows folder and select calc.exe Explorer.exe /select,c:\windows\calc.exe
Display single pane view with drive m selected Explorer.exe /e, /select, "m:\"

Explorer [/n] [/e] [(,)/root,<object>] [/select,<object>]

/n                Opens a new single-pane window for the default
selection. This is usually the root of the drive Windows
is installed on. If the window is already open, a
duplicate opens. /e Opens Windows Explorer in its default view. /root,<object> Opens a window view of the specified object. /select,<object> Opens a window view with the specified folder, file or
application selected. Examples: Example 1: Explorer /select,C:\TestDir\TestApp.exe Opens a window view with TestApp selected. Example 2: Explorer /e,/root,C:\TestDir\TestApp.exe This opens Explorer with C: expanded and TestApp selected. Example 3: Explorer /root,\\TestSvr\TestShare Opens a window view of the specified share. Example 4: Explorer /root,\\TestSvr\TestShare,select,TestApp.exe Opens a window view of the specified share with TestApp selected.