我正在构建一个MVC 3项目,该项目需要在 Controller 中按路径引用位于该项目的\bin\
文件夹中的程序集。
有人可以指出正确的方向来构建\bin\
文件夹的相对路径吗?
在VS 2010中以 Debug模式运行项目会导致当前目录为C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0
,因此使用.\bin\
在该路径中查找bin
文件夹。
谢谢
最佳答案
您可以使用当前的appdomain来获取此信息。
// 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");
关于asp.net-mvc-3 - MVC 3到./bin/的相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7188757/