繁体   English   中英

ASP.NET MVC和IIS Express-更改执行目录

[英]ASP.NET MVC and IIS Express - Change executing directory

当前,我正在研究应该使用现有框架的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中执行 可以更改此目录吗?

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 files \\“部分,其余的其他文件夹仍将存在

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM