Sometimes when deploying .NET code in IIS6 I can't rename or delete the .NET application folder because it's in use. The only thing that seems to fix it is stopping the w3svc service, doing what I need to do then starting it again.
This isn't ideal when there are other web applications being served on the web server. Just stopping that particular virtual web site doesn't seem to work either.
Is there a better way to do this?
Try this:
Drop the AppOffline.aspx file in the directory where you want to make changes. That will allow you to rename or delete that directory or any folders/files therein. I always deploy with a file named AppOfflineNOT.aspx. Then remove/replace the "NOT" as needed. This way you don't have to mess with iis when updating your site.
There is a similar question here: How to get IIS7 to release a locked file?
If you really need to frequently change that, you can,
Here is a very simple way to get around all of the above.
This will do a start and stop of the service and will free up any lingering processes before you do your code refresh. Just be ready to push your code as soon as the command is done to avoid anyone jumping on to the server and creating a lock. I usually write an xcopy script to run immediately after.