How to define relative paths in Visual Studio Project?

Viewed 211467

I have a library and a console application that uses a library. The library has a folder with source and header files.

My project is in a child/inner directory but that library directory that I want to include is in a parent/upper directory.

My project directory:

H:\Gmail_04\gsasl-1.0\lib\libgsaslMain

Includes files are here:

H:\Gmail_04\gsasl-1.0\src

How can I use paths relative to the project directory, to include folders that are in a parent/upper directory?

5 Answers

There are a couple of hints you need to know.

consider your app is running under c:\MyRepository\MyApp

a single dot on your path means the folder where your app runs. So if you like to reach some folder or file under MyApp folder (imagine c:\MyRepository\MyApp\Resources\someText.txt) you can do it like var bla = File.Exists(./Resources/someText.txt)

and you can go one level up with double dots (..) think about a folder under c:\MyRepository\SomeFolder\sometext.txt for MyApp, it will be like var bla = File.Exists(../SomeFolder/someText.txt)

and it is possible to go 2,3,4.. levels up like

../../SomeFolder (2 levels up)

../../../SomeFolder (3 levels up)

and path starting with no dots means the drive root. var bla = File.Exists(/SomeFolder/someText.txt) will look for the c:\SomeFolder\someText.txt in our scenario.

Related