Executing or Opening Application or document file at Runtime using System.Diagnostics in C#

In this blog we are going to see, How to Open or Execute the Application or document file at run time using C#.

 

Summary:

             Starts a process resource by specifying the name of a document or application and associates the resource with a new System.Diagnostics.Process component.

       

filename

 

The name of a document or application files to run in the process.

       

Returns:

 

A new System.Diagnostics.Process component that is associated with the process

resource, or null, if no process resource is started (for example, if an

existing process is reused).

Used Namespace:

System.Diagnostics

Code Snippet:

protected void Page_Load(object sender, EventArgs e)

        {

            //Opens the document or application specified as Name.

            System.Diagnostics.Process.Start(@"C:\IMG_2824.JPG");

            //Opens the .CHM file.

            System.Diagnostics.Process.Start(@"C:\ebook.chm");

      System.Diagnostics.Process.Start(@"C:\book.exe");

            //Opens the Word Document

            System.Diagnostics.Process.Start(@"C:\word.docx");

        }

 

 

 

Thanks for reading this article. Have a nice day.