Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My requirement is I wanna delete Asp.net temp files for every 24 hours.



C#
string net_base = Path.GetFullPath(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), @"..\.."));
            string strTemp32 = string.Concat(net_base, @"\Framework\", RuntimeEnvironment.GetSystemVersion(), @"\Temporary ASP.NET Files");


System.IO.File.Delete(strTemp32);
I'm getting the following error. when deleting this files in temp.


Access to the path 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files' is denied.
Posted
Updated 20-Feb-15 5:44am
v2

1 solution

First question is why do you want to do this?

However, the reason you are getting that error is because something still has the files open. It may be Visual Studio or it may be IIS. You would either need to make sure all programs and services are closed or you can loop through each folder and try to delete and if there is an error just move on.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900