C#中 - 如何删除Internet临时文件临时文件、Internet

由网友(竖起中指操起生活)分享简介:我要清除Internet临时文件夹彻底。该文件夹的位置,例如, C:\ Users \用户名\ AppData \本地\微软\的Windows \ Temporary Internet Files文件,取决于Windows版本,所以它有是动态的。I want to clear the temporary Intern...

我要清除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:UsersUsernameAppDataLocalMicrosoftWindowsTemporary 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
}
阅读全文

相关推荐

最新文章