Jul
04
2005
Deleting temporary files
Posted by admin under
.NET
In a project I recently was part of I needed to (dynamically) create *A LOT* of PDF-files and other files as well for viewing. The thing was that these files were not supposed to saved on the webserver, they were supposed to be temporary only.
My solution was to simply delete them after a while, so I wrote a function (DeleteOldTempFiles) and had that called every now and then. (I didn't call it on every page request to save some computing power).
EEEContent_1
As you can see I prefixed all created files with "temp-", i.e temp-1111-222-333.pdf.
Also, note that the physical path is supposed to be passed and you can get that from the server variable APPL_PHYSICAL_PATH and then append the virtual directory where your tempfiles are stored - below it's "/tempdir".
EEEContent_2