C#退出网页时,无需用户操作即可删除服务器上的文件和文件夹 [英] C# On Quit WebPage Delete Files and Folders on Server with no user action

查看:226
本文介绍了C#退出网页时,无需用户操作即可删除服务器上的文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户未完成网页中的某些操作并退出其他网页时,删除服务器上的临时文件夹和文件时会遇到一些问题。创建页面加载文件夹的初始位置是为了允许用户加载文件。我曾尝试在Idisposable期间实施销毁,但没有成功。当用户不执行任何操作或取消按钮而退出页面时,有人可以指出删除文件夹和文件的最佳方法。

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 quit the page with no action or cancel button.

推荐答案

您可以调查页面的OnUnload事件,但老实说,最好的选择是定期运行脚本并删除临时文件夹中的所有文件早于合理数量。例如在午夜运行,并删除24小时之前创建的所有文件(如果磁盘空间有问题,则删除更少的文件)。

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).

这篇关于C#退出网页时,无需用户操作即可删除服务器上的文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆