473,398 Members | 2,525 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,398 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 41536
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.