Resolved File question from a new guy

zendog1960

Member
Joined
Jan 9, 2008
Messages
19
Programming Experience
Beginner
Good Morning Folks,

I am having trouble with this and have had an extremely difficult time finding any type of solution online so I come to you, the gurus, for help.

I have a form with a tabbed control on it. Each tab in the control simply loads an existing file in a reader to display to the user. I have added the files in a folder in my project. When I debug it works great. However, when I publish and move it to another computer, the program runs fine but none of the files show in the tab control tabs. The files do come with the solution when I publish.

The following code is an example of how each tab calls the file.

VB.NET:
    Private Sub Tab01_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tab01.Enter
        Me.AxAcroPDF3.LoadFile("C:\VS Projects\Client\Project\Resources\Volume1\Contract Addendum.pdf")
    End Sub

I know there is a way to make the file path "relative" but I cannot figure out how and there really isn't many resources available to explain how this can be done.

Any and all help would be greatly appreciated. Thanks!
 
Last edited:
Hello.

You could try My.Application.Info.DirectoryPath...like this:
VB.NET:
Imports System.IO

Me.AxAcroPDF3.LoadFile(Path.Combine(My.Application.Info.DirectoryPath, "\Resources\Volume1\Contract Addendum.pdf"))

Bobby
 
Thanks Bobby

Hello.

You could try My.Application.Info.DirectoryPath...like this:
VB.NET:
Imports System.IO

Me.AxAcroPDF3.LoadFile(Path.Combine(My.Application.Info.DirectoryPath, "\Resources\Volume1\Contract Addendum.pdf"))

Bobby

Thanks Bobby. That worked. Since I have many many files to load in various forms I decided to do this in each for to help eliminate the typing!!

VB.NET:
Public Class Form 1
    Dim varPath as String = My.Application.Info.DirectoryPath

    Private Sub Tab01_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tab01.Enter
        Me.AxAcroPDF3.LoadFile(varPath & "\Resources\Volume1\Contract Addendum.pdf")
    End Sub

Tested it on several forms and works great!
 
Back
Top