Connecting Tech Pros Worldwide Help | Site Map

Link labels to relative paths on the local machine

Newbie
 
Join Date: Feb 2009
Posts: 18
#1: Mar 19 '09
Hi, I would like to create a link in my program that will open a file stored in a directory relative to the program itself.
e.g. if the program is in the program folder, the file I want to open is program/data/file.html.

I have no trouble creating links to websites or files specified with an absolute path but have been unable to open a file using a relative path. Any help would be appreciated.
AJ
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,761
#2: Mar 19 '09

re: Link labels to relative paths on the local machine


Take a look at these. You should be able to put them together to get what you need.

Expand|Select|Wrap|Line Numbers
  1. Application.ExecutablePath;
  2. System.IO.Directory.GetParent;
Newbie
 
Join Date: Feb 2009
Posts: 18
#3: Mar 20 '09

re: Link labels to relative paths on the local machine


Thank you very much, the following worked:

HelpFileLink.Links[0].LinkData = "file:///" + System.IO.Directory.GetParent( Application.ExecutablePath ).FullName + "/data/Help.html"

If it wasn't for the need to specify the "file:" protocol just using "./data/Help.txt" works.
Reply

Tags
label, link, path file, relative