ObjectSharp Blogs

You are currently viewing

Bruce Johnson's SOA(P) Box

Using SOA in the .NET world


Opening a File by Association

For a simple application, which I hope to share with you shortly, I needed to be able to launch the application associated with a particular file type.  For example, if you had a file called 'test.log' and the '.log' extension was associated with UltraEdit32, I wanted to launch UltraEdit32 and load up test.log.  While I could have located the file association in the registry and launched the application, there is an easier way.  Use the Process class to execute “test.log” as a command and let Windows do the rest.

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = “test.log“;
proc.Start();

I can't get over how nicely the little things in the .NET Framework fit together.  It's almost like someone...what's the word...designed it ;)

Comments

    No Comments

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS