3

I am trying to delete temporary asp.net files from C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary. Some ASP.NET files and some folders get deleted but for some folders I have to open each folder and then delete them manually.

Have set the property of folder as NOT READ ONLY but still some files do not get deleted.

It is very time consuming. Is there any property I can set which can help me delete all the files/folders at once?

meghna
  • 31

2 Answers2

1

This is a very old question, but I think my answer can help many visitors.

Usually the folder is in use by IIS and cannot be deleted. One technique is to stop IIS before deleting. I prefer to delete the folder several times because that causes the locks to be released.

If the website is in use, it will display errors during the deletion.

Lately I have been using this script in powershell:

#Requires -RunAsAdministrator

While (Get-ChildItem "C:\Windows\Microsoft.NET\Framework\v\Temporary ASP.NET Files" -Recurse) { Get-ChildItem "C:\Windows\Microsoft.NET\Framework\v\Temporary ASP.NET Files" -Recurse | Remove-Item -Recurse -ErrorAction SilentlyContinue -Confirm:$false -Force }

Victor Sanchez
  • 220
  • 2
  • 8
0

(IF you running on IIS local) Just Stop IIS service, then you can delete all folders.

Stop IIS -> CMD -> iisreset /stop; Start IIS -> CMD -> iisreset /start;

(IF you running on IISEXPRESS) Close the iisexpress service, delete folders then running it back.

Marcos
  • 9