ASP.NET Schedule deletion of temporary files

前端 未结 8 1182
暗喜
暗喜 2021-01-06 00:38

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 di

8条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-06 01:08

    I sort of agree with whats said in the answer by dirk.

    The idea being that the temp folder in which you drop the files to is a fixed known location however i differ slightly ...

    1. Each time a file is created add the filename to a list in the session object (assuming there isn't thousands, if there is when this list hits a given cap do the next bit)

    2. when the session ends the Session_End event should be raised in global.asax should be raised. Iterate all the files in the list and remove them.

提交回复
热议问题