如何在VS 2005中使用C#Windows应用程序清除Internet缓存. [英] How do I clean Internet Cache using C# Windows application in VS 2005. .

查看:80
本文介绍了如何在VS 2005中使用C#Windows应用程序清除Internet缓存.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在VS 2005中使用C#Windows应用程序清理Internet缓存.

How do I clean Internet Cache using C# Windows application in VS 2005.

推荐答案

Internet缓存文件存储在"Temporary Internet Files"文件夹中.因此,基本上您需要做的是删除该文件夹中存在的所有文件.为了做到这一点;

The internet cache files are stored in ''Temporary Internet Files'' folder. So basically what you need to do is to delete all the files that are present in that folder. In order to do this;

private void EmptyCacheFolder(DirectoryInfo folder)
{
    foreach (FileInfo file in folder.GetFiles())
    { 
        file.Delete(); 
    }
    foreach (DirectoryInfo subfolder in folder.GetDirectories())
    { 
        EmptyCacheFolder(subfolder); 
    }
}

public bool ClearCache()
{
    bool isEmpty;
    try
    {
        EmptyCacheFolder(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)));
        isEmpty = true;
    }
    catch
    {
        isEmpty = false;
    }    
    return isEmpty;
}


这篇关于如何在VS 2005中使用C#Windows应用程序清除Internet缓存.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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