How to open a file in it's default program

  • Thread starter Thread starter Tor Inge Rislaa
  • Start date Start date
T

Tor Inge Rislaa

How to open a file in it's default program

A file with the extention .doc will normally be opened in Microsoft Word if
it is doubleclicked in a filebrowser, a file with the extention .htm will
normally be opened in Internet explorer. Is there a way to benefit from the
operating systems handling of default programs for opening known filetypes?

I need a VB.NET code where I can give a filename e.g.
"c:\mycatalog\myfile.doc" and let the code execute the right program for the
actual file.

Any Ideas

T.I.Rislaa
 
Sure, no problem - here is a sample:

Dim p As New System.Diagnostics.Process
Dim s As New System.Diagnostics.ProcessStartInfo("C:\data\ct.txt")
s.UseShellExecute = True
s.WindowStyle = ProcessWindowStyle.Normal
p.StartInfo = s
p.Start()

Jerry
 
Tor Inge Rislaa said:
How to open a file in it's default program

A file with the extention .doc will normally be opened in Microsoft
Word if it is doubleclicked in a filebrowser, a file with the
extention .htm will normally be opened in Internet explorer. Is there
a way to benefit from the operating systems handling of default
programs for opening known filetypes?

I need a VB.NET code where I can give a filename e.g.
"c:\mycatalog\myfile.doc" and let the code execute the right program
for the actual file.

Any Ideas

Have a look at Process.Start
 
* "Tor Inge Rislaa said:
A file with the extention .doc will normally be opened in Microsoft Word if
it is doubleclicked in a filebrowser, a file with the extention .htm will
normally be opened in Internet explorer. Is there a way to benefit from the
operating systems handling of default programs for opening known filetypes?

I need a VB.NET code where I can give a filename e.g.
"c:\mycatalog\myfile.doc" and let the code execute the right program for the
actual file.

\\\
Dim psi As New ProcessStartInfo()
With psi
.FileName = "C:\bla.doc"
.UseShellExecute = True
End With
Process.Start(psi)
///
 
Back
Top