Use relative path

Ryanshirt

New member
Joined
Sep 8, 2005
Messages
3
Location
Switzerland, Z
Hi Folks...

Is it possible to use a relative Path to open a File with the System.IO.File ?

In ASP.Net or similar Langs you can use .open("../../file.txt").

Do I have to use the absolut path to open a file in VB.Net, I cant even
remeber how it was in VB6. Anyway if someone has a answer to my question or a better sugestion how to handle files let me know.
 
Well you can use one of:

System.Windows.Forms.Application.ExecutablePath
System.Windows.Forms.Application.StartupPath
System.AppDomain.CurrentDomain.BaseDirectory()
System.GetEntryAssembly().Location

to get the application path and in asp.net there is server.mappath(). Therefore just use Application.StartupPath & "relative path" for example.

:)
 
Back
Top