开发者

C# On Quit WebPage Delete Files and Folders on Server with no user action

I have some problems to delete temporary folder and files on my server when users not finish some action in webpages and quit to other webpages. Initialy at Page Load folders are created to allow the user to load files.I have tried implementing destruction during Idisposable without success. Could someone point the best method to delete folders and files when user开发者_C百科 quit the page with no action or cancel button.


You can investigate the OnUnload event of the page but, honestly, your best bet is to have a script run periodically and delete all files from the temp folder older than some reasonable amount. e.g. run at midnight and delete all files created more the 24 hours ago (or less, if disk space is a problem).


I am not sure why you want to create temp folders and files. But deleting them on no action is ugly way to rely on, because you have depend on some timers. You could use System.IO.Path.GetTempPath() to get a temp file and system would take care of deletion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜