3

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?

chaliasos
  • 9,659
  • 7
  • 50
  • 87

3 Answers3

3

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

VS Variables

$(ProjectDir)

gives the project directory

juergen d
  • 201,996
  • 37
  • 293
  • 362
  • 4
    Thanks for your answer. How can I use it in my code? If I use it like this: `string projectDir = "$(ProjectDir)"` it is just parsing it like "$(ProjectDir)". – chaliasos Apr 28 '12 at 11:30
2

I finally found a solution to my problem:

string projectDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
chaliasos
  • 9,659
  • 7
  • 50
  • 87
0

You can also simply use Environment.CurrentDirectory

shakram02
  • 10,812
  • 4
  • 22
  • 21