View file based on it's file type - extension

R

Ryan

I pass a filename to a method which needs to open that file up with the
aPPlication associated with that filename. If the file MyFile.txt then the
method should open it up in Notepad,. If MyFile.doc is passed then it should
be open up in MS Word.
I am using vs2005.
 
Z

zacks

Use the Process class, passing the document name as the  
ProcessStartInfo.FileName used.  As long as you don't change the default  
value of ProcessStartInfo.UseShellExecute from "true", the Process class  
will use the Windows Explorer shell's file type associations to launch the  
appropriate program.

Pete

The quick and dirty method is to:

Process.Start("filename");
 

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