除了用以下方式:
https://rexyuan0502.blogspot.com/2019/01/c_11.html
也可以使用下列方式執行:
using System.Diagnostics;
using System.ComponentModel;
class MyProcess
{
public string g_StrFullPath = "C:\\Test\\NSServer.exe";
public string g_StrPath = "C:\\Test";
public string g_StrName = "NSServer.exe";
// Opens the Internet Explorer application.
void OpenApplication(string myFavoritesPath)
{
// Start Internet Explorer. Defaults to the home page.
Process.Start(g_StrFullPath);
// Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath);
}
// Opens urls and .html documents using Internet Explorer.
void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process.Start(g_StrFullPath, g_StrPath);
// Start a Web page using a browser associated with .html and .asp files.
Process.Start(g_StrFullPath, g_StrPath);
Process.Start(g_StrFullPath, g_StrPath);
}
// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo(g_StrFullPath);
startInfo.WindowStyle = ProcessWindowStyle.Normal;
Process.Start(startInfo);
startInfo.Arguments = g_StrPath;
Process.Start(startInfo);
}
public void Main()
{
// Get the path that stores favorite links.
string myFavoritesPath =
Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
MyProcess myProcess = new MyProcess();
//myProcess.OpenApplication(myFavoritesPath);
//myProcess.OpenWithArguments();
myProcess.OpenWithStartInfo();
}
}
使用方式 可放到namespace 中 拆解使用