1. 程式人生 > >C#中使用程序開啟檔案和應用程式

C#中使用程序開啟檔案和應用程式

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _01程序
{
    class Program
    {
        static void Main(string[] args)
        {
           

            //使用程序來開啟應用程式
            //Process.Start("notepad");//開啟記事本
            //Process.Start("mspaint");//開啟畫圖工具
            //Process.Start("iexplore", "http://www.baidu.com");
            //Process.Start("calc");//開啟計算器


            //使用程序來開啟檔案


            //封裝我們要開啟的檔案 但是並不去開啟這個檔案
            ProcessStartInfo psi = new ProcessStartInfo(@"C:\Users\SpringRain\Desktop\開啟檔案練習.exe");
            //建立程序物件
            Process pro = new Process();
            //告訴程序要開啟的檔案資訊
            pro.StartInfo = psi;
            //呼叫函式開啟
            pro.Start();
            Console.ReadKey();
        }
    }
}