Shelling?

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi,

Does anyone know how to open up a file using its
application extension. i.e open up a .doc in word, .xls
in excel,etc?

Any help much appreciated.

John
 
Does anyone know how to open up a file using its
application extension. i.e open up a .doc in word, .xls
in excel,etc?

System.Diagnostics.Process.Start("x:\dir\yourfile.doc");



Mattias
 
Thanks, however the below will throw an error if it can't
find a matching file type, is there anyway around this?
 
What workaround would you propose? Are you hoping to see the same dialog
box that comes up under Windows Explorer?
--- N

Thanks, however the below will throw an error if it can't
find a matching file type, is there anyway around this?
 
If it can't find a matching type, and you don't tell it how to open the
file, you will most certainly get an exception. Easiest thing to do is to
register the type. Next easiest thing to do is to start a copy of the
application and pass the name of the document as a command line argument.
Every office app will allow you to do this but you'll have to look at the
documentaion to find out if it is something like c:\>excel
x:\dir\yourfile.xls or something like c:\>excel -f x:\dir\yourfile.xls
 
Back
Top