How to get a project directory from a Visual Studio add-in

I want to get a project related to an add-in. But if I use the following code:

string projectDir = Directory.GetCurrentDirectory();

he returns C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\

How can I get the project directory of a project that uses the add-in?

+3
source share
3 answers

I finally found a solution to my problem:

string projectDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+2
source

See here for a list of Visual Studio variables that you can use.

VS variables

$(ProjectDir)

provides a project directory

+2
source

Environment.CurrentDirectory

0

All Articles