473,669 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Link labels to relative paths on the local machine

18 New Member
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
Mar 19 '09 #1
2 2748
tlhintoq
3,525 Recognized Expert Specialist
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;
Mar 19 '09 #2
Asja
18 New Member
Thank you very much, the following worked:

HelpFileLink.Li nks[0].LinkData = "file:///" + System.IO.Direc tory.GetParent( Application.Exe cutablePath ).FullName + "/data/Help.html"

If it wasn't for the need to specify the "file:" protocol just using "./data/Help.txt" works.
Mar 20 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2774
by: Doug | last post by:
If I were to write an include with a relative path like include("../conf/config.php"); What is the use? As far as I understand it, the path is relative to the first script that is called by php. In other words, if the current working directory is /www/ and you were
5
4108
by: jason | last post by:
Can anyone help me find a solution to quickly working out relative paths to a folder in the root of my server... Although it easy when you go - say - two levels down: .../includes it becomes increasingly difficult to ball park the folder when you go deeper and wider down:
2
2366
by: Alex | last post by:
Hi. I need some help on this. I have a user control (a header) in my root directory, and all my pages use that control. Then a created a folder (in my root directory) and put a new page inside it, and that page use the same control, but this time the control can't find it's images and resources because it is trying to find it in the same folder instead of the root directory. Now, I know that I can change the control image's relative paths...
3
1252
by: tsteinke | last post by:
Okay so I had some aspx pages with document relative links to images and webusercontrols (which also have doc relative pats to images) I wanted to use forms authentication on, so I was forced to move the pages to a sub directory, which in turn broke all my links. Ok well I could go over the 100 or so links by hand and change them to ../images/ instead of images/ and prefix all my usercontrols with ../ but there is still trouble. Because...
9
1743
by: Garann Means | last post by:
I have a subfolder under wwwroot set up as a virtual directory with its own application name in IIS. I pulled it down from Visual Source Safe and, on the machine where it's normally hosted, it works fine. On my machine, though, all the application relative paths are resolving relative to wwwroot. Can anyone tell me what I might be doing wrong? Thanks!
23
5355
by: wylbur37 | last post by:
I'm running an Apache server on my own computer (Windows XP Pro). I wrote a simple PHP script (called test3.php) that I'm running by putting the following URL in the address bar of the browser (Firefox) .... http://localhost/test3.php The script generates the following link using the echo statement ...
2
6982
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the Content Page? TIA
8
2596
by: JJ | last post by:
I'm confused about paths. I have a functionn that uses the mappath method, which I think requires a virtual path (is that the same as a relative path?). But this doesn't always work as the path can take the form of the following: 1. /directory/images/xyz.gif (works fine) 2. http://localhost:1234/www.mytestwebsite.com/directory/images/xyz.gif (doesn't work) 3. http:///www.someremotesite.com/directory/images/abc.gif (doesn't work)
15
6458
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would make it much easier to slap modualar blocks of markup into page frameworks, which may change and so forth. And the few extra bytes, which even for a fairly large site would not amount to as many bytes as are in a fairly small low-res image, should...
0
8465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8383
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8895
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8809
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.