Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 3 relative path to ./bin/

Tags:

I'm building an MVC 3 project which requires a reference, by path, in the controller to an assembly sitting in the \bin\ folder of the project.

Can anybody point me in the right direction to constructing a relative path to the \bin\ folder?

Running the project in debug mode in VS 2010 causes the current directory to be C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0, so using .\bin\ looks for a bin folder in that path.

Thanks

like image 485
Andy Hunt Avatar asked Aug 25 '11 10:08

Andy Hunt


1 Answers

You could use current appdomain to get this information.

// 1) get current directory for this loaded assembly // 2) combine path to get \bin folder  var path = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "bin"); 
like image 84
Muttok Avatar answered Nov 02 '22 14:11

Muttok