提供對本地和遠程進程的訪問權限並使你能夠啓動和停止本地系統進程。
Process可以打開文件,也可以打開exe的運行程序
現在先來說一下如何打開word文檔:
string fileNewPat = Application.StartupPath;
string fileName = fileNewPat+@"\doc\程沐喆.doc";
if (File.Exists(fileName))
{
Process process1 = new Process();
process1.StartInfo.FileName = fileName;
process1.StartInfo.Arguments = "";
process1.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
process1.Start();
}
else
{
MessageBox.Show("文件不存在");
}
打開Config文件:
string stConfigFileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
stConfigFileName = Path.Combine(stConfigFileName, "UserConfigSettings");
stConfigFileName += @".config";
打開Windows自帶的計算器程序:
Process process1 = new Process();
process1.StartInfo.FileName = "calc.exe";
process1.StartInfo.Arguments = "";
process1.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
process1.Start();