簡體   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