重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

C#之使用Process打开文件

提供对本地和远程进程的访问权限并使你能够启动和停止本地系统进程。

成都创新互联10多年企业网站建设服务;为您提供网站建设,网站制作,网页设计及高端网站定制服务,企业网站建设及推广,对成都PE包装袋等多个方面拥有多年的营销推广经验的网站建设公司。

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();

当前标题:C#之使用Process打开文件
文章出自:http://cqcxhl.com/article/gioicp.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP