By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,570 Members | 1,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,570 IT Pros & Developers. It's quick & easy.

opening File/Dir with default application (also without extension)

P: n/a
Hi,

From my VB.NET 2005 application I need to be able to open Files an
Directory's with their default application:
- A word-doc must open in word
- A excell-document in Excel etc
- in case it's a folder it must open the Folder

No problem there, but when I want to open a file without extension, that
hasn't offcourse a default application, I'm getting an error. I'd prefer to
have the "Choose Program"-dialog.

Any idea how I should open the files to have this?

Thanks a lot in advance,

Pieter
I'm using this now:

Dim prcLogin As New Process
Try
prcLogin.StartInfo.UseShellExecute = True
prcLogin.StartInfo.RedirectStandardOutput = False
prcLogin.StartInfo.FileName = strName
If strArg <> "" Then
prcLogin.StartInfo.Arguments = strArg
End If
prcLogin.Start()
Catch ex As Exception
MessageBox.Show("Can't open the file!", MessageBoxButtons.OK,
MessageBoxIcon.Error) '-> happens when the file doesn't have an
extension....
End Try
prcLogin.Close()
Nov 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try using:
System.Diagnostics.Process.Start(FileName)

"Pieter" wrote:
Hi,

From my VB.NET 2005 application I need to be able to open Files an
Directory's with their default application:
- A word-doc must open in word
- A excell-document in Excel etc
- in case it's a folder it must open the Folder

No problem there, but when I want to open a file without extension, that
hasn't offcourse a default application, I'm getting an error. I'd prefer to
have the "Choose Program"-dialog.

Any idea how I should open the files to have this?

Thanks a lot in advance,

Pieter
I'm using this now:

Dim prcLogin As New Process
Try
prcLogin.StartInfo.UseShellExecute = True
prcLogin.StartInfo.RedirectStandardOutput = False
prcLogin.StartInfo.FileName = strName
If strArg <> "" Then
prcLogin.StartInfo.Arguments = strArg
End If
prcLogin.Start()
Catch ex As Exception
MessageBox.Show("Can't open the file!", MessageBoxButtons.OK,
MessageBoxIcon.Error) '-> happens when the file doesn't have an
extension....
End Try
prcLogin.Close()

Nov 23 '05 #2

P: n/a
"Pieter" <pi**********@hotmail.com> schrieb:
From my VB.NET 2005 application I need to be able to open Files an
Directory's with their default application:
- A word-doc must open in word
- A excell-document in Excel etc
- in case it's a folder it must open the Folder

No problem there, but when I want to open a file without extension, that
hasn't offcourse a default application, I'm getting an error. I'd prefer
to have the "Choose Program"-dialog.


Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>

+

Displaying the "Open with..." dialog
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openwithdialog&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #3

P: n/a
Thanks Herfried! That was exactly waht I was looking for!

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ep**************@TK2MSFTNGP15.phx.gbl...
"Pieter" <pi**********@hotmail.com> schrieb:
From my VB.NET 2005 application I need to be able to open Files an
Directory's with their default application:
- A word-doc must open in word
- A excell-document in Excel etc
- in case it's a folder it must open the Folder

No problem there, but when I want to open a file without extension, that
hasn't offcourse a default application, I'm getting an error. I'd prefer
to have the "Choose Program"-dialog.


Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>

+

Displaying the "Open with..." dialog
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openwithdialog&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #4

P: n/a
td
This works for me!
Thanks Simon
Terry

"Simon" wrote:
Try using:
System.Diagnostics.Process.Start(FileName)

"Pieter" wrote:
Hi,

From my VB.NET 2005 application I need to be able to open Files an
Directory's with their default application:
- A word-doc must open in word
- A excell-document in Excel etc
- in case it's a folder it must open the Folder

No problem there, but when I want to open a file without extension, that
hasn't offcourse a default application, I'm getting an error. I'd prefer to
have the "Choose Program"-dialog.

Any idea how I should open the files to have this?

Thanks a lot in advance,

Pieter
I'm using this now:

Dim prcLogin As New Process
Try
prcLogin.StartInfo.UseShellExecute = True
prcLogin.StartInfo.RedirectStandardOutput = False
prcLogin.StartInfo.FileName = strName
If strArg <> "" Then
prcLogin.StartInfo.Arguments = strArg
End If
prcLogin.Start()
Catch ex As Exception
MessageBox.Show("Can't open the file!", MessageBoxButtons.OK,
MessageBoxIcon.Error) '-> happens when the file doesn't have an
extension....
End Try
prcLogin.Close()

Jan 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.