在c#中的特定时间删除asp.net临时文件 [英] Delete asp.net temporary files at particular time in c#

查看:68
本文介绍了在c#中的特定时间删除asp.net临时文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是我想每24小时删除一次Asp.net临时文件。







My requirement is I wanna delete Asp.net temp files for every 24 hours.



string net_base = Path.GetFullPath(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), @"..\.."));
            string strTemp32 = string.Concat(net_base, @"\Framework\", RuntimeEnvironment.GetSystemVersion(), @"\Temporary ASP.NET Files");





System.IO .File.Delete(strTemp32);

我收到以下错误。在temp中删除这些文件的时候。





访问路径'C:\ Windows\Microsoft.NET\Framework \\ \\ _v4.0.30319 \Temporary ASP.NET Files'被拒绝。



System.IO.File.Delete(strTemp32);
I'm getting the following error. when deleting this files in temp.


Access to the path 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files' is denied.

推荐答案

第一个问题是你为什么要这样做?



但是,您收到该错误的原因是因为某些文件仍然打开了。它可能是Visual Studio,也可能是IIS。您需要确保所有程序和服务都已关闭,或者您可以遍历每个文件夹并尝试删除,如果有错误,请继续。
First question is why do you want to do this?

However, the reason you are getting that error is because something still has the files open. It may be Visual Studio or it may be IIS. You would either need to make sure all programs and services are closed or you can loop through each folder and try to delete and if there is an error just move on.


这篇关于在c#中的特定时间删除asp.net临时文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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