目前我正在开发一个应该使用现有框架的ASP.NET MVC应用程序。我在IIS Express中托管这个ASP.NET MVC应用程序。此框架的某些类假定文件相对于当前目录。现在,程序集在 c:\ users \ MyName \ appdata \ local \ temp \ temporary asp.net files \ root \ 3c076611 \ 5261f232 \ assembly \ dl3 \ d36edef7 \ e39ad394_8136d101 <中执行/ strong>即可。 是否可以更改此目录?
答案 0 :(得分:0)
var rootLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
现在将文件加载为
var filePath = Path.Combine(rootLocation,"relative path to your assembly");
编辑:
如果你不能改变框架,那么你可以使用web.config更改临时目录,添加<compilation tempDirectory="C:\Project\Temp\">
,但这只会改变“c:\ users \ MyName \ appdata \ local \ temp \ temporary asp.net文件\“部分,其他文件夹仍将存在