473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to open a file in it's default program

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

Nov 20 '05 #1
4 41515
Sure, no problem - here is a sample:

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

Jerry

"Tor Inge Rislaa" <to*************@rislaa.no> wrote in message
news:iV******************@news4.e.nsc.no...
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

Nov 20 '05 #2
"Tor Inge Rislaa" <to*************@rislaa.no> schrieb
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
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
Thank you for quick response an useful code example

TIR
"Tor Inge Rislaa" <to*************@rislaa.no> skrev i melding
news:iV******************@news4.e.nsc.no...
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

Nov 20 '05 #4
* "Tor Inge Rislaa" <to*************@rislaa.no> scripsit:
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)
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael | last post by:
Hello, Not sure if this is the right message board but I have an interesting problem. Using Visual Studio .NET, C++, I want to write an all-encompassing C++ program to download new files from...
0
by: ungvichian | last post by:
I am trying to write a program in VC++.Net that will read a text file with wireframe data in it and display the wireframe it represents. This link has a sample of the code I'm basing my program off...
4
by: DyslexicAnaboko | last post by:
Hello, I have a module that is part of larger project that is giving me trouble, so I setup an example. Brief ===== I simply want to open a text file and make the contents avaliable...
3
by: nickvans | last post by:
Hi all, I have a database which is used to narrow down and select part drawings. The drawings are stored as .jpg files. I have a table relating the the part number to the file containing the...
3
by: lumpybanana247 | last post by:
i finally found out how to set my registry to open a certain extension with my little text editor. For instance, when you set notepad to open the file, you just set the value to...
3
by: BASSPU03 | last post by:
Private Sub FilePath_Click() Rem Me! Dim stAppName As String Dim stlink As String stlink = Me! stAppName = "C:\Program Files\Internet Explorer\IEXPLORE.EXE...
2
by: =?Utf-8?B?TmFt?= | last post by:
Version: .NET Framework 2.0 In my Windows Forms application, how can I open a file in its native program?. Let’s say a listbox displays a list of file names with full paths; when a user double...
1
jkmyoung
by: jkmyoung | last post by:
I am attempting to automatically open .xml files with a .bat script when I open them. Microsoft XP 2002 SP 2 Ultimate goals: 1. Figure out how Open With list is stored. 2. Edit Open With...
1
by: sisobaby | last post by:
i want a code that can be written in VB 6.3 to open file when i press F1(or any key) the name of source program that open this file is CHS.exe and saved in C:\DeltaV\bin. the name of the file...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.