views:

1391

answers:

3

I have a VB.NET program that I wish to to publish. In the code it references a HTML page that I created. Instead of having the URL hard coded (example: www.test2.com/folder/index.html)

I would like to have it relative to wherever the encoder is installed to (example: /folder/index.html)

How can I do this?

Thanks!

+2  A: 

Hi

In VB.Net you have either

Dim lPath As String = Application.ExecutablePath

Which gives you the full path and app.name (which you can remove) or

Dim lPath As String = Application.StartupPath

Which gives you the directory the application started up in ..


Not sure I know the answer to the clickonce question, as we use our own deployment method at work but if you :-

  1. Add your file via Project Explorer
  2. Right click on file, select properties and set Build Action to "content"
  3. Go to Project, yourprojectnameProperties, then Publish tab, then Application Files button
  4. you should see the file listed there then set to Include(auto).

.... or copy and paste them using internet explorer into the project explorer

spacemonkeys
Um... your code samples are the same.
Larsenal
@Larsenal - Opps, thanks corrected
spacemonkeys
I am able to get the Application.StartupPath to work, but how do I have the folder/files included when I publish?
Bruno43
@Bruno43, I've updated my answer to include what I understand of click once, hope it helps
spacemonkeys
I used your Application.StartupPath and then all I had to do was copy the folder with all the html and images and paste it into the solution Explorer. Easy... Thanks
Bruno43
A: 

If the file is referenced within your solution, the publish operation should automatically include the file to be published.

as for reference, if the html is hosted with in same website, then you can use a relative path from the page you are linking to.

N8
A: 

You can also reference the file in your code by using Server.MapPath("relativepathtofile") and the relative path to the file you're referencing.

Birk