How can I remove Bin DLL Files from within a ASP.NET App?
When I try it on IIS 7.5, it says "Permission denied".
I wrote a codebehind script, to remove DLL files from within the bin directory. The code snippet is as below:
string[] filesList = Directory.GetFiles(System.Web.HttpRuntime.BinDirectory, "*.dll");
foreach (string f in filesList)
{
try
{
File.Delete(f);
app.Context.Response.Write("R: " + f + "\n");
}
catch (IOException deleteError)
{
app.Context.Response.Write(deleteError.Message);
}
}
It works fine on the VisualStudio IIS Express, but doesn't work on a production IIS 7.5 server.
您将需要以管理员身份运行IIS,然后重置IIS并暂时停止asp.net应用程序,然后可以打开Bin文件夹并删除DLL。
By default, IIS watches the bin
folder automatically, any change to it will cause an immediate Application-Pool recycle.
You can change this setting in IIS manager though:
Application Pools > [Your_App_Pool] > Advance Settings > Disable Recycling for Configuration Changes = True
.
See TechNet
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.