chaliasos
chaliasos

Reputation: 9783

How to get the project directory from a Visual Studio Add-in

I want to get the project directroy from an Add-In. But if I use the following code:

string projectDir = Directory.GetCurrentDirectory();

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

How can I get the Project Directory of the project that uses the Add-In?

Upvotes: 3

Views: 4569

Answers (3)

shakram02
shakram02

Reputation: 11826

You can also simply use Environment.CurrentDirectory

Upvotes: 0

chaliasos
chaliasos

Reputation: 9783

I finally found a solution to my problem:

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

Upvotes: 2

juergen d
juergen d

Reputation: 204766

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

VS Variables

$(ProjectDir)

gives the project directory

Upvotes: 3

Related Questions