Question: I have an ASP.NET application which creates temporary PDF files (for the user to download).
Now, many users over many days can create many PDFs, which take much disk space.
What’s the best way to schedule deletion of files older than 1 day/ 8 hours ?
Preferably in the asp.net application itselfs…
For each temporary file that you need to create, make a note of the filename in the session:
Next, add the following cleanup code to global.asax:
UPDATE: I’m now accually using a new (improved) method than the one described above. The new one involves HttpRuntime.Cache and checking that the files are older than 8 hours. I’ll post it here if anyones interested. Here’s my new global.asax.cs: