Home All Groups Group Topic Archive Search About
Author
27 Jun 2005 2:09 AM
Jack Russell
Why doesn't the following code run acrobat?
It throws a file not found exception

Thanks

         Dim s As String = sgAppPath + "TCW3Help.pdf"
         Try
             If Not File.Exists(s) Then
                 MsgBox("Cannot find " + s, MsgBoxStyle.Exclamation)
             Else
                 s = """" + s + """"
                 Shell(s)
             End If
         Catch ex As FileNotFoundException
             MsgBox("Unable to open Help file " + s + " check that
Acrobat is installed", MsgBoxStyle.Exclamation)
         Catch ex As Exception
             ReportBug(ex, "Trying to open help file " + s)
         End Try

Author
27 Jun 2005 6:19 AM
Crouchie1998
Try this:

        Dim s As String = Application.StartupPath & "\TCW3Help.pdf"
        Try
            If Not IO.File.Exists(s) Then
                MessageBox.Show(String.Format("Cannot find {0}", s),
Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Else
                Microsoft.VisualBasic.Shell(s, AppWinStyle.NormalFocus)
            End If
        Catch ex As IO.FileNotFoundException
            MessageBox.Show(String.Format("Unable to open Help file {0}.
Check that Acrobat is installed", s), Me.Text, MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
        Catch ex As Exception
            MessageBox.Show(ex, "Trying to open help file " + s)
        End Try

I hope this helps

Crouchie1998
BA (HONS) MCP MCSE
Author
27 Jun 2005 7:13 AM
Jack Russell
Thanks but still get the same thing, exception on the shell command.

Any other ideas?

Crouchie1998 wrote:
Show quoteHide quote
> Try this:
>
>         Dim s As String = Application.StartupPath & "\TCW3Help.pdf"
>         Try
>             If Not IO.File.Exists(s) Then
>                 MessageBox.Show(String.Format("Cannot find {0}", s),
> Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
>             Else
>                 Microsoft.VisualBasic.Shell(s, AppWinStyle.NormalFocus)
>             End If
>         Catch ex As IO.FileNotFoundException
>             MessageBox.Show(String.Format("Unable to open Help file {0}.
> Check that Acrobat is installed", s), Me.Text, MessageBoxButtons.OK,
> MessageBoxIcon.Exclamation)
>         Catch ex As Exception
>             MessageBox.Show(ex, "Trying to open help file " + s)
>         End Try
>
> I hope this helps
>
> Crouchie1998
> BA (HONS) MCP MCSE
>
>
Author
27 Jun 2005 7:21 AM
Crouchie1998
I changed the filename to one on my system & it worked for me. Just play
around with the Try Catch End Try block.

Sorry, but I don't have the time to do anything else for the next 3-4 hours,
but later if you don't have a solution then I'll re-write it for you.

Crouchie1998
BA (HONS) MCP MCSE
Author
27 Jun 2005 8:29 AM
Jack Russell
Thanks, still no joy but took Cors suggestion and used process.start -
no problems.
One thing I can say for .net, there seem to a thousand ways of doing
anything and one eventually works!



Crouchie1998 wrote:

Show quoteHide quote
> I changed the filename to one on my system & it worked for me. Just play
> around with the Try Catch End Try block.
>
> Sorry, but I don't have the time to do anything else for the next 3-4 hours,
> but later if you don't have a solution then I'll re-write it for you.
>
> Crouchie1998
> BA (HONS) MCP MCSE
>
>
Author
27 Jun 2005 11:52 AM
Crouchie1998
I just recoded your solution because that's the way you wanted to code it.
Process.Start is an easier way, I agree

Crouchie1998
BA (HONS) MCP MCSE
Author
27 Jun 2005 7:33 AM
Cor Ligthert
Jack,

Did you try it already with Process.Start(filenme)
(Needs a reference to be set).

Pdf, should of couse start when you click in explorer on that, otherwise you
have to name the program in this method as well.

In addition when you try something, set than first the hardcoded path in it,
that makes finding an error much easier.

I hope this helps,

Cor
Author
27 Jun 2005 8:28 AM
Jack Russell
Cor,

Thanks that worked!



Cor Ligthert wrote:
Show quoteHide quote
> Jack,
>
> Did you try it already with Process.Start(filenme)
> (Needs a reference to be set).
>
> Pdf, should of couse start when you click in explorer on that, otherwise you
> have to name the program in this method as well.
>
> In addition when you try something, set than first the hardcoded path in it,
> that makes finding an error much easier.
>
> I hope this helps,
>
> Cor
>
>
Author
27 Jun 2005 8:10 AM
Herfried K. Wagner [MVP]
"Crouchie1998" <crouchie1998@spamcop.net> schrieb:
>        Dim s As String = Application.StartupPath & "\TCW3Help.pdf"

=> 'System.IO.Path.Combine'.  Otherwise the path will contain two
backslashes if the application is installed to a drive's root directory.

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