Log in

View Full Version : Relative Path Problem


luckylaeeq
04-16-2007, 07:52 AM
Hi Guys ,

Wanted to know how we can have relative path ..... e.g if i want to show a picture which is present in the same folder ... how i can do that without harcoding entire path .... for desktop application

Regards

Laeeq Ahmad

BobbyCannon
04-18-2007, 03:54 PM
C#:

string aPath1 = Application.ExecutablePath;
string aPath2 = Application.StartupPath;

System.Reflection
You can also use the System.Reflection namespace to get the properties of your Assembly. Try this VB.NET code:

Dim aPath As String
Dim aName As String

aName = _
System.Reflection.Assembly.GetExecutingAssembly. _
GetModules()(0).FullyQualifiedName

aPath = System.IO.Path.GetDirectoryName(aName)

Or

aPath = System.Reflection.Assembly. _
GetExecutingAssembly.Location