Executing an external file from C#

Hello everyone again!

Thanks for the help on the last problem I was running into!

This time around, I am trying to execute a file from my code based on its filetype.

What I have done is:

1) Given a path, I have loaded the information into a byte array
2) Saved a referrence to the file into a database

Now, given the referrence, I need to 

1) execute the file in its default viewer, ex:
    .doc = Launch Microsoft Word
    .pdf  = Launch Adobe Acrobat Reader
    .txt  = Launch NotePad

And so on.....so given the path of the file, I just want to execute it with its default application.

Anybody point me to the right method or class to execute the file object

Thanks!

Tree


Answer this question

Executing an external file from C#

  • Hexar Anderson

    Check out the System.Diagnostics.Process.Start method. You can pass in a filename and it will launch the associated application and load the file.

    -Karl Erickson

  • Oleg Ovetchkine MSFT

    System.Diagnostics.Process.Start()

    Look into the System.Diagnosotics.Process namespace...

    It has some good stuff in it.

    Just a thought

  • HScottBuck

    Great!

    Thanks everyone!

    (Viking/Karl, that is :))

  • Executing an external file from C#