Hi everyone,

I am having problem with the relative path in VB.Net.

My project contains PDF file that reside on the same directory as all project files. I am using WebBorwser control to open that PDF file.
The code below shows what I am doing to display the PDF file, and it works fine

Private Sub FindBidderHelp_Load(ByVal sender As System.Object, ByVal e As  System.EventArgs) Handles MyBase.Load

Me.WebBrowser1.Navigate("N:\Project\Project\FUUN\FUUN\FilesPDF\FindExis tedBidderInstruction.pdf")

End Sub

However when I move the project on another drive or machine the code above stops working.

I have tried to do something like in asp.net

“~FilesPDF\FindExistedBidderInstruction.pdf" but it did not work.

Then I moved the PDF file to the application’s bin/debug directory and changed the code in the form load event to the

Me.WebBrowser1.Navigate (Application.StartupPath & " FilesPDF \FindExis tedBidderInstruction.pdf")

But it didn't not make any changes.
I can’t understand what I am missing here. Everything I need is to create relative path so that I can use my application on any machine or drive

Thank you for any help

Mika

Answering my own question.

What I missed is the "\" in the relative path .

So the correct code is:

Me.WebBrowser1.Navigate (Application.StartupPath & " \FilesPDF \FindExis tedBidderInstruction.pdf")

Hi everyone,

I am having problem with the relative path in VB.Net.

My project contains PDF file that reside on the same directory as all project files. I am using WebBorwser control to open that PDF file.
The code below shows what I am doing to display the PDF file, and it works fine

Private Sub FindBidderHelp_Load(ByVal sender As System.Object, ByVal e As  System.EventArgs) Handles MyBase.Load

Me.WebBrowser1.Navigate("N:\Project\Project\FUUN\FUUN\FilesPDF\FindExis tedBidderInstruction.pdf")

End Sub

However when I move the project on another drive or machine the code above stops working.

I have tried to do something like in asp.net

“~FilesPDF\FindExistedBidderInstruction.pdf" but it did not work.

Then I moved the PDF file to the application’s bin/debug directory and changed the code in the form load event to the

Me.WebBrowser1.Navigate (Application.StartupPath & " FilesPDF \FindExis tedBidderInstruction.pdf")

But it didn't not make any changes.
I can’t understand what I am missing here. Everything I need is to create relative path so that I can use my application on any machine or drive

Thank you for any help

Mika

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.