C#中 - 如何删除Internet临时文件 [英] C# - How to Delete temporary internet files

查看:180
本文介绍了C#中 - 如何删除Internet临时文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要清除Internet临时文件夹彻底。该文件夹的位置,例如, C:\ Users \用户名\ AppData \本地\微软\的Windows \ Temporary Internet Files文件,取决于Windows版本,所以它有是动态的。

I want to clear the temporary Internet files folder completely. The location of the folder, e.g., C:\Users\Username\AppData\Local\Microsoft\Windows\Temporary Internet Files, depends on the version of Windows, so it has to be dynamic.

推荐答案

使用此路径:的 Environment.SpecialFolder.InternetCache

use this path: Environment.SpecialFolder.InternetCache

string path = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)
//for deleting files
System.IO.DirectoryInfo di = new DirectoryInfo(path);
foreach (FileInfo file in di.GetFiles())
{
    file.Delete(); 
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
    dir.Delete(true); //delete subdirectories and files
}

这篇关于C#中 - 如何删除Internet临时文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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