Starting a process by extension association...

R

Ray Mitchell

Hello,

From within a C# application I would like to start a process based upon the
default process associated with a specific file extension. For example, if I
provide File.doc as an argument, I want Word (or whatever application is
currently associated with .doc files) to start and open file File.doc. On
the other hand, if I provide File.wav as an argument, I want MediaPlayer (or
whatever application is currently associated with .wav files) to open and
used File.wav. I know how to use the Process class to start a specific
application, but what do I need to do to start an application with which a
particular extension is associated?

Thanks,
Ray
 
R

Ray Mitchell

Peter Duniho said:
[...] if I provide File.wav as an argument, I want MediaPlayer (or
whatever application is currently associated with .wav files) to open and
used File.wav. I know how to use the Process class to start a specific
application, but what do I need to do to start an application with which
a
particular extension is associated?

By default, Process/ProcessStartInfo does just what you want. Just
provide the name of the file you want opened instead of an executable, and
Process will use the Windows shell to map the file type to the associated
application.

Pete

Thanks Pete,

I knew it had to be simple! I'll try it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top