0

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

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

1
Contributor
1
Reply
5
Views
6 Years
Discussion Span
Last Post by Mikayil
0

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

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.