好的,所以我們在IIS中有一個運行在ASP.NET 4.0上的CMS站點。如何通過網站更新IIS上的站點中的文件?
用戶想在網站上更新了一些圖片,而是因爲他們最近已經擔任了,IIS已經向他們開放的一個手柄,鎖定的文件。這導致用戶接收要上傳的文件的更新版本時,下面的錯誤:
The process cannot access the file 'X:\inetpub\wwwroot\sitename\Images\Banner\Temp\5.jpg' because it is being used by another process.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: The process cannot access the file 'X:\inetpub\wwwroot\sitename\Images\Banner\Temp\5.jpg' because it is being used by another process.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[IOException: The process cannot access the file 'X:\inetpub\wwwroot\sitename\Images\Banner\Temp\5.jpg' because it is being used by another process.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +14328663
System.IO.File.InternalDelete(String path, Boolean checkHost) +14293114
Admin_Settings_EditHomePageBanner.btnSave_Click(Object sender, ImageClickEventArgs e) +1109
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +134
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +204
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
有什麼辦法,以編程方式在ASP.NET代碼告訴IIS來釋放它的緩存的句柄文件這樣它可能會更新?顯然,回收整個IIS過程在這裏並不是一個可行的方法。