在 C# 中使用文件名启动应用程序

using System.Diagnostics;

    Process p = new Process();

    p.StartInfo.FileName = @"你的应用程序的完整物理路径";

    p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;//该属性在WinForm中有效

    p.StartInfo.UseShellExecute = true;

    p.StartInfo.CreateNoWindow = true;

    p.Start();

http://blog.csdn.net/godpreserve/archive/2008/05/19/2458476.aspx

HOW TO:在 C# 中使用文件名启动应用程序

本文的发布号曾为 CHS306222
本文讨论一种 Microsoft 产品的 Beta 版本。本文中的信息按"原样"提供,如有更改恕不另行通知。

对于该 Beta 产品,Microsoft 不提供正式的产品支持。有关获取对 Beta 版本的支持的信息,请参阅 Beta 产品文件中包括的文档资料,或查看您下载此版本的站点。

本页

概要
本文演示了如何启动与某一给定文档扩展名或文件类型关联的应用程序而又无须知道该关联应用程序的名称或位置。例如,您可以用一个与 .bmp 文件扩展名关联的应用程序启...

本文演示了如何启动与某一给定文档扩展名或文件类型关联的应用程序而又无须知道该关联应用程序的名称或位置。例如,您可以用一个与 .bmp 文件扩展名关联的应用程序启动 Arcade.bmp 文件,多数情况下此应用程序就是 MSPaint.exe。

要求

  • Microsoft C# .Net

包括名称空间

名称空间必须出现在类声明之前,如下所示:
using System.Diagnostics;

指定 ProcessStartInfo 信息

您可以使用 .NET 框架 Process 类的 ProcessStartInfo 结构来指定启动进程时的选项。本文概述了如何使用文件名选项。另一个成员 UseShellExecute 指定基于文件扩展名或文件类型而非基于可执行文件 (.exe) 的名称来启动进程。此属性默认设置为 true。出于演示目的,它在本代码中是显式设置的。
string sysFolder=
                            Environment.GetFolderPath(Environment.SpecialFolder.System);
                            ProcessStartInfo pInfo = new ProcessStartInfo();
                            pInfo.FileName = sysFolder + @"\eula.txt";
                            pInfo.UseShellExecute = true;

启动应用程序

此示例打开一个名为 Eula.txt 的文件。此文件是用与 .txt 文件扩展名关联的应用程序打开的,此应用程序通常就是 Notepad.exe。您可以替换为任何有相关联应用程序的文件名或文件类型。
Process p  = Process.Start(pInfo);

创建启动应用程序的快捷方式

因为 UseShellExecute 默认为"true",所以在启动进程时不要求您使用 ProcessStartInfo 。您可以使用一行代码来启动关联的应用程序,如下所示:
Process p  = Process.Start(@"C:\winnt\system32\eula.txt");

完成代码示例

using System.Diagnostics;
                            //Get path of the system folder.
                            string sysFolder =
                            Environment.GetFolderPath(Environment.SpecialFolder.System);
                            //Create a new ProcessStartInfo structure.
                            ProcessStartInfo pInfo = new ProcessStartInfo();
                            //Set the file name member.
                            pInfo.FileName = sysFolder + @"\eula.txt";
                            //UseShellExecute is true by default. It is set here for illustration.
                            pInfo.UseShellExecute = true;
                            Process p  = Process.Start(pInfo);

疑难解答

个别计算机有可能未安装关联应用程序或注册表中的关联不正确。最好将此代码包装在一个 try...catch 块中,这样在失败时应用程序就会收到警报。

http://support.microsoft.com/kb/306222/zh-cn

using System;

        using System.Collections.Generic;

        using System.ComponentModel;

        using System.Data;

        using System.Drawing;

        using System.Text;

        using System.Windows.Forms;

        using System.IO;

        using System.Runtime.InteropServices;

        using System.Security;

        using System.Diagnostics; //命名空间提供特定的类,使您能够与系统进程、事件日志和性能计数器进行交互。

        namespace WindowsApplication1

        {

            /// <summary>

            /// 启动本机系统程序

            /// 只需要把程序的exe文件写入Process.Start("")中就行

            /// </summary>

            public partial class Form1 : Form

            {

                public Form1()

                {

                    InitializeComponent();

                }

                private void button1_Click(object sender, EventArgs e)

                {

                    Process.Start("calc.exe");//计算器

                }

                private void button2_Click(object sender, EventArgs e)

                {

                    Process.Start("TTPlayer.exe");

                }

                private void button3_Click(object sender, EventArgs e)

                {

                    Process.Start("IEXPLORE.EXE");

                }

            }

        }从C中启动本机应用程序 - hblhwcoree - hblhwcoree的博客

http://blog.sina.com.cn/s/blog_5f0814cd0100c3n8.html

c# 启动外部程序打开文件
2007年12月02日 星期日 12:56

             /// <summary>
            /// 打开指定文件(.txt,.xls(x),.doc(x),...)
            /// </summary>
            /// <param name="fileName">要打开的文件名,包含路径</param>
            private void OpenFiles(string fileName)
            {
                  try
                  {
                        if (fileName != "" && System.IO.File.Exists(fileName))
                        {
                              System.Diagnostics.Process.Start(fileName);
                        }
                  }
                  catch (System.Exception e)
                  {
                        MessageBox.Show("打开文件失败" + e.Message);
                  }
            }

http://hi.baidu.com/goga/blog/item/1fccb1516d77551b377abe2e.html

原文地址:https://www.cnblogs.com/xianyin05/p/1450011.html