急!需要一个清理C# webbrowser 缓存的类.
  • 收藏任务 (1)
  • 订阅任务
  • 分享任务
    • 分享说明:

此任务所属分类:任务大厅 > 程序 > 模块

稿件编号:3371002号    
  • gjhjack1980
  • 卖家评价
  • 能力:9
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 09:43:51 评论:0票数:38 | 分享稿件 | 客户积分兑换礼品 下载附件 

  您好,请加QQ12339597,,我发你解压密码,,这个是那个类的原文件+代码。  

做威客,首选金牌会员,更多收入,更多客户

稿件编号:3377709号    
  • 364920352
  • 卖家评价
  • 能力:0
  • 认证: 未实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/07/01 10:19:15 评论:0票数:37 | 分享稿件 | 客户积分兑换礼品     第一个方法是把自己的网页写到一个临时文件,然后navigate到这个文件,Foxmail是这样做的。这样做的缺点是会产生很多临时文件,文件在磁盘上的读写需要耗费较多时间,而且要记得及时清理。

  
第二个方法是用COM中IPersistStreamInit之类的,使用流操作,据说Outlook便是这样做的。这样显然是最好的,在内存中形成网页进行操作速度也很快。但我在.Net里找不到这个接口,所以不知道如何实现。应用程序操作浏览器/网页:  WebBrowser浏览器控件提供了一些函数,如ExecWB,可以使浏览器执行内部定义的一些操作,如执行另存为:  webBrowser.ExecWB( SHDocVw.OLECMDID.OLECMDID_SAVEAS, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref objNull, ref objNull );  但似乎这里按取消的话会抛出一个异常,所以我用一个空的try{}catch(Exception){}来捕获它,就不会有错误了。  还可以用DOM里的一些方法来操作网页,举个例子,可以这样调用网页中写好的一个Javascript函数func():  ((mshtml.HTMLDocumentClass)webBrowser.Document).parentWindow.execScript( "func()", "JScript" );  

30秒玩转团队空间,成交机率增加5倍

稿件编号:3380525号    
  • xenonx
  • 卖家评价
  • 能力:0
  • 认证: 未实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/07/01 17:01:47 评论:0票数:81 | 分享稿件 | 客户积分兑换礼品 下载附件 

  *************************
说明

*************************
由于缓存文件是特殊的文件,以及WebBrowser与IE版本有关
因此删除缓存绝对不可能用一些IO函数就总可以解决的
因此我的这些函数在IO操作的基础上,又针对环境进行相应的清理。


static class WebCleaner
{
/*
* 7 个静态函数

* 私有函数
* private bool FileDelete() : 删除文件
* private void FolderClear() : 清除文件夹内的所有文件
* private void RunCmd() : 运行内部命令
*
* 公有函数
* public void CleanCookie() : 删除Cookie
* public void CleanHistory() : 删除历史记录
* public void CleanTempFiles() : 删除临时文件
* public void CleanAll() : 删除所有
*
*
*
* */


//private


///
/// 删除一个文件,System.IO.File.Delete()函数不可以删除只读文件,这个函数可以强行把只读文件删除。
///
/// 文件路径
/// 是否被删除
static bool FileDelete(string path)
{
//first set the File's ReadOnly to 0
//if EXP, restore its Attributes

System.IO.FileInfo file = new System.IO.FileInfo(path);
System.IO.FileAttributes att = 0;
bool attModified = false;

try
{
//### ATT_GETnSET
att = file.Attributes;
file.Attributes &= (~System.IO.FileAttributes.ReadOnly);
attModified = true;

file.Delete();
}
catch (Exception e)
{
if (attModified)
file.Attributes = att;

return false;
}

return true;
}

//public

///
/// 清除文件夹
///
/// 文件夹路径
static void FolderClear(string path)
{
System.IO.DirectoryInfo diPath = new System.IO.DirectoryInfo(path);
foreach (System.IO.FileInfo fiCurrFile in diPath.GetFiles())
{
FileDelete(fiCurrFile.FullName);

}
foreach (System.IO.DirectoryInfo diSubFolder in diPath.GetDirectories())
{
FolderClear(diSubFolder.FullName); // Call recursively for all subfolders
}
}

static void RunCmd(string cmd)
{
System.Diagnostics.Process.Start("cmd.exe", "/c " + cmd);
}

///
/// 删除历史记录
///
public static void CleanHistory()
{
string[] theFiles = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.History), "*", System.IO.SearchOption.AllDirectories);
foreach (string s in theFiles)
FileDelete(s);
RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1");
}
///
/// 删除临时文件
///
public static void CleanTempFiles()
{
FolderClear(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
}
///
/// 删除Cookie
///
public static void CleanCookie()
{
string[] theFiles = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Cookies), "*", System.IO.SearchOption.AllDirectories);
foreach (string s in theFiles)
FileDelete(s);
RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2");
}
///
/// 删除全部
///
public static void CleanAll()
{
CleanHistory();
CleanCookie();
CleanTempFiles();
}
}  

三大利器,助团队会员投标更有优势

稿件编号:3381204号    
  • chlixuan
  • 卖家评价
  • 能力:2
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/07/01 18:30:00 评论:0票数:89 | 分享稿件 | 客户积分兑换礼品 下载附件 

  提供了两种清除方式,详见Readme.text。

附带一个测试小程序。

解压密码通过短消息发给你。

如有疑问,请联系QQ:8六97五8348  

升级个人空间,立刻让你与众不同

稿件编号:3390516号    
  • 康萍一生
  • 卖家评价
  • 能力:0
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/07/03 11:41:37 评论:0票数:50 | 分享稿件 | 客户积分兑换礼品 下载附件 

  在附件中,看看好不好用.  

一分钟开通团队空间,你的优势立刻展现在客户面前

稿件编号:3392040号    
  • maidianshop
  • 卖家评价
  • 能力:14
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 金牌会员
发布者已浏览 时间:2009/07/03 15:34:42 评论:0票数:56 | 分享稿件 | 客户积分兑换礼品 下载附件 

  由本人编写的,绝对好用  

稿件编号:3379839号    
  • tyougyokuki
  • 卖家评价
  • 能力:1
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/07/01 15:39:07 评论:0票数:31 | 分享稿件 | 客户积分兑换礼品   http://www.namipan.com/d/DeleteCache.rar/6cf2e65cb6acadd1edb5da9ae69fbae63df43072e0379400
链接地址是演示文件,下载后双击html文件即可在浏览器中观看演示.
如果您觉得满足您的需要,请和我联系索取源文件!
谢谢!!!  

稿件编号:3370890号    
  • yanminmin
  • 卖家评价
  • 能力:8
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:1
  • 好评:100
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 09:26:48 评论:0票数:0 | 分享稿件 | 客户积分兑换礼品   要在 Visual C#.NET 中,使用 WinInet 函数清除所有缓存中文件


using System;
using System.Runtime.InteropServices;

// Visual C# version of Q326201
namespace Q326201CS
{
// Class for deleting the cache.
class DeleteCache
{
// For PInvoke: Contains information about an entry in the Internet cache
[StructLayout(LayoutKind.Explicit, Size=80)]
public struct INTERNET_CACHE_ENTRY_INFOA
{
[FieldOffset(0)] public uint dwStructSize;
[FieldOffset(4)] public IntPtr lpszSourceUrlName;
[FieldOffset(8)] public IntPtr lpszLocalFileName;
[FieldOffset(12)] public uint CacheEntryType;
[FieldOffset(16)] public uint dwUseCount;
[FieldOffset(20)] public uint dwHitRate;
[FieldOffset(24)] public uint dwSizeLow;
[FieldOffset(28)] public uint dwSizeHigh;
[FieldOffset(32)] public FILETIME LastModifiedTime;
[FieldOffset(40)] public FILETIME ExpireTime;
[FieldOffset(48)] public FILETIME LastAccessTime;
[FieldOffset(56)] public FILETIME LastSyncTime;
[FieldOffset(64)] public IntPtr lpHeaderInfo;
[FieldOffset(68)] public uint dwHeaderInfoSize;
[FieldOffset(72)] public IntPtr lpszFileExtension;
[FieldOffset(76)] public uint dwReserved;
[FieldOffset(76)] public uint dwExemptDelta;
}

// For PInvoke: Initiates the enumeration of the cache groups in the Internet cache
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="FindFirstUrlCacheGroup",
CallingConvention=CallingConvention.StdCall)]
public static extern IntPtr FindFirstUrlCacheGroup(
int dwFlags,
int dwFilter,
IntPtr lpSearchCondition,
int dwSearchCondition,
ref long lpGroupId,
IntPtr lpReserved);

// For PInvoke: Retrieves the next cache group in a cache group enumeration
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="FindNextUrlCacheGroup",
CallingConvention=CallingConvention.StdCall)]
public static extern bool FindNextUrlCacheGroup(
IntPtr hFind,
ref long lpGroupId,
IntPtr lpReserved);

// For PInvoke: Releases the specified GROUPID and any associated state in the cache index file
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="DeleteUrlCacheGroup",
CallingConvention=CallingConvention.StdCall)]
public static extern bool DeleteUrlCacheGroup(
long GroupId,
int dwFlags,
IntPtr lpReserved);

// For PInvoke: Begins the enumeration of the Internet cache
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="FindFirstUrlCacheEntryA",
CallingConvention=CallingConvention.StdCall)]
public static extern IntPtr FindFirstUrlCacheEntry(
[MarshalAs(UnmanagedType.LPTStr)] string lpszUrlSearchPattern,
IntPtr lpFirstCacheEntryInfo,
ref int lpdwFirstCacheEntryInfoBufferSize);

// For PInvoke: Retrieves the next entry in the Internet cache
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="FindNextUrlCacheEntryA",
CallingConvention=CallingConvention.StdCall)]
public static extern bool FindNextUrlCacheEntry(
IntPtr hFind,
IntPtr lpNextCacheEntryInfo,
ref int lpdwNextCacheEntryInfoBufferSize);

// For PInvoke: Removes the file that is associated with the source name from the cache, if the file exists
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="DeleteUrlCacheEntryA",
CallingConvention=CallingConvention.StdCall)]
public static extern bool DeleteUrlCacheEntry(
IntPtr lpszUrlName);

[STAThread]
static void Main(string[] args)
{
// Indicates that all of the cache groups in the user's system should be enumerated
const int CACHEGROUP_SEARCH_ALL = 0x0;
// Indicates that all the cache entries that are associated with the cache group
// should be deleted, unless the entry belongs to another cache group.
const int CACHEGROUP_FLAG_FLUSHURL_ONDELETE = 0x2;
// File not found.
const int ERROR_FILE_NOT_FOUND = 0x2;
// No more items have been found.
const int ERROR_NO_MORE_ITEMS = 259;
// Pointer to a GROUPID variable
long groupId = 0;

// Local variables
int cacheEntryInfoBufferSizeInitial = 0;
int cacheEntryInfoBufferSize = 0;
IntPtr cacheEntryInfoBuffer = IntPtr.Zero;
INTERNET_CACHE_ENTRY_INFOA internetCacheEntry;
IntPtr enumHandle = IntPtr.Zero;
bool returnValue = false;

// Delete the groups first.
// Groups may not always exist on the system.
// For more information, visit the following Microsoft Web site:
// http://msdn.microsoft.com/library/?url=/workshop/networking/wininet/overview/cache.asp
// By default, a URL does not belong to any group. Therefore, that cache may become
// empty even when the CacheGroup APIs are not used because the existing URL does not belong to any group.
enumHandle = FindFirstUrlCacheGroup(0, CACHEGROUP_SEARCH_ALL, IntPtr.Zero, 0, ref groupId, IntPtr.Zero);
// If there are no items in the Cache, you are finished.
if (enumHandle != IntPtr.Zero && ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error())
return;

// Loop through Cache Group, and then delete entries.
while(true)
{
// Delete a particular Cache Group.
returnValue = DeleteUrlCacheGroup(groupId, CACHEGROUP_FLAG_FLUSHURL_ONDELETE, IntPtr.Zero);
if (!returnValue && ERROR_FILE_NOT_FOUND == Marshal.GetLastWin32Error())
{
returnValue = FindNextUrlCacheGroup(enumHandle, ref groupId, IntPtr.Zero);
}

if (!returnValue && (ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error() || ERROR_FILE_NOT_FOUND == Marshal.GetLastWin32Error()))
break;
}

// Start to delete URLs that do not belong to any group.
enumHandle = FindFirstUrlCacheEntry(null, IntPtr.Zero, ref cacheEntryInfoBufferSizeInitial);
if (enumHandle == IntPtr.Zero && ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error())
return;

cacheEntryInfoBufferSize = cacheEntryInfoBufferSizeInitial;
cacheEntryInfoBuffer = Marshal.AllocHGlobal(cacheEntryInfoBufferSize);
enumHandle = FindFirstUrlCacheEntry(null, cacheEntryInfoBuffer, ref cacheEntryInfoBufferSizeInitial);

while(true)
{
internetCacheEntry = (INTERNET_CACHE_ENTRY_INFOA)Marshal.PtrToStructure(cacheEntryInfoBuffer, typeof(INTERNET_CACHE_ENTRY_INFOA));

cacheEntryInfoBufferSizeInitial = cacheEntryInfoBufferSize;
returnValue = DeleteUrlCacheEntry(internetCacheEntry.lpszSourceUrlName);
if (!returnValue)
{
returnValue = FindNextUrlCacheEntry(enumHandle, cacheEntryInfoBuffer, ref cacheEntryInfoBufferSizeInitial);
}
if (!returnValue && ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error())
{
break;
}
if (!returnValue && cacheEntryInfoBufferSizeInitial > cacheEntryInfoBufferSize)
{
cacheEntryInfoBufferSize = cacheEntryInfoBufferSizeInitial;
cacheEntryInfoBuffer = Marshal.ReAllocHGlobal(cacheEntryInfoBuffer, (IntPtr) cacheEntryInfoBufferSize);
returnValue = FindNextUrlCacheEntry(enumHandle, cacheEntryInfoBuffer, ref cacheEntryInfoBufferSizeInitial);
}
}
Marshal.FreeHGlobal(cacheEntryInfoBuffer);
}
}
}  

稿件编号:3370919号    
  • zenghd
  • 卖家评价
  • 能力:38
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 09:31:44 评论:0票数:0 | 分享稿件 | 客户积分兑换礼品   WebBrowser是共用IE的缓存,只要清空IE的缓存,WebBrowser的缓存自然会清会
IE的缓存是保存在C:\Documents and Settings\sz\Local Settings\Temporary Internet Files文件下,
只要删除这个文件夹的文件就行了
另外,清空缓存好像不会提高性能反而会降低性能  

稿件编号:3370948号    
  • gjhjack1980
  • 卖家评价
  • 能力:9
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 09:36:01 评论:0票数:22 | 分享稿件 | 客户积分兑换礼品 下载附件 

  这是一个压缩的word文件,里面是清缓存的代码,不知道合不合要求。请加我QQ12339597,,我发你rar文件的解压密码。  

稿件编号:3370977号    
  • taiyy2002
  • 卖家评价
  • 能力:21
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 09:40:51 评论:0票数:35 | 分享稿件 | 客户积分兑换礼品 下载附件 

  我已经根据你的需要编写了个
希望对你有用·!
稿件加密·!密码站内发送~!  

稿件编号:3370983号    
  • yanminmin
  • 卖家评价
  • 能力:8
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:1
  • 好评:100
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 09:41:10 评论:0票数:0 | 分享稿件 | 客户积分兑换礼品   WinInet 函数
要清除缓存直接,您可以使用以下 WinInet 函数:
使用 FindFirstURLCacheEntry 函数以查找第一个缓存条目。
使用 FindNextUrlCacheEntry 函数来枚举缓存。
使用 DeleteUrlCacheEntry 函数删除每个项。
本文中的此代码示例使用所有这些功能。

注意 : 这些函数仅可用于 Microsoft Internet Explorer 5。 因此,必须包含适当检查本文中的代码示例包括) 以防止出现错误。


回到顶端
清除缓存 Visual C#.NET 中的步骤
要在 Visual C#.NET 中,使用 WinInet 函数清除所有缓存中文件,请按照下列步骤:
启动 Microsoft Visual Studio.NET。
在 文件 菜单上指向 新建 ,然后单击 项目 。
在在 新建项目 对话框中单击 项目类型 下的 Visual C# 项目 ,然后单击 模板 下的 控制台应用程序 。
将以下代码添加到 Class 1 类:
using System;
using System.Runtime.InteropServices;

// Visual C# version of Q326201
namespace Q326201CS
{
// Class for deleting the cache.
class DeleteCache
{
// For PInvoke: Contains information about an entry in the Internet cache
[StructLayout(LayoutKind.Explicit, Size=80)]
public struct INTERNET_CACHE_ENTRY_INFOA
{
[FieldOffset(0)] public uint dwStructSize;
[FieldOffset(4)] public IntPtr lpszSourceUrlName;
[FieldOffset(8)] public IntPtr lpszLocalFileName;
[FieldOffset(12)] public uint CacheEntryType;
[FieldOffset(16)] public uint dwUseCount;
[FieldOffset(20)] public uint dwHitRate;
[FieldOffset(24)] public uint dwSizeLow;
[FieldOffset(28)] public uint dwSizeHigh;
[FieldOffset(32)] public FILETIME LastModifiedTime;
[FieldOffset(40)] public FILETIME ExpireTime;
[FieldOffset(48)] public FILETIME LastAccessTime;
[FieldOffset(56)] public FILETIME LastSyncTime;
[FieldOffset(64)] public IntPtr lpHeaderInfo;
[FieldOffset(68)] public uint dwHeaderInfoSize;
[FieldOffset(72)] public IntPtr lpszFileExtension;
[FieldOffset(76)] public uint dwReserved;
[FieldOffset(76)] public uint dwExemptDelta;
}

// For PInvoke: Initiates the enumeration of the cache groups in the Internet cache
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="FindFirstUrlCacheGroup",
CallingConvention=CallingConvention.StdCall)]
public static extern IntPtr FindFirstUrlCacheGroup(
int dwFlags,
int dwFilter,
IntPtr lpSearchCondition,
int dwSearchCondition,
ref long lpGroupId,
IntPtr lpReserved);

// For PInvoke: Retrieves the next cache group in a cache group enumeration
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="FindNextUrlCacheGroup",
CallingConvention=CallingConvention.StdCall)]
public static extern bool FindNextUrlCacheGroup(
IntPtr hFind,
ref long lpGroupId,
IntPtr lpReserved);

// For PInvoke: Releases the specified GROUPID and any associated state in the cache index file
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="DeleteUrlCacheGroup",
CallingConvention=CallingConvention.StdCall)]
public static extern bool DeleteUrlCacheGroup(
long GroupId,
int dwFlags,
IntPtr lpReserved);

// For PInvoke: Begins the enumeration of the Internet cache
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="FindFirstUrlCacheEntryA",
CallingConvention=CallingConvention.StdCall)]
public static extern IntPtr FindFirstUrlCacheEntry(
[MarshalAs(UnmanagedType.LPTStr)] string lpszUrlSearchPattern,
IntPtr lpFirstCacheEntryInfo,
ref int lpdwFirstCacheEntryInfoBufferSize);

// For PInvoke: Retrieves the next entry in the Internet cache
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="FindNextUrlCacheEntryA",
CallingConvention=CallingConvention.StdCall)]
public static extern bool FindNextUrlCacheEntry(
IntPtr hFind,
IntPtr lpNextCacheEntryInfo,
ref int lpdwNextCacheEntryInfoBufferSize);

// For PInvoke: Removes the file that is associated with the source name from the cache, if the file exists
[DllImport(@"wininet",
SetLastError=true,
CharSet=CharSet.Auto,
EntryPoint="DeleteUrlCacheEntryA",
CallingConvention=CallingConvention.StdCall)]
public static extern bool DeleteUrlCacheEntry(
IntPtr lpszUrlName);

[STAThread]
static void Main(string[] args)
{
// Indicates that all of the cache groups in the user's system should be enumerated
const int CACHEGROUP_SEARCH_ALL = 0x0;
// Indicates that all the cache entries that are associated with the cache group
// should be deleted, unless the entry belongs to another cache group.
const int CACHEGROUP_FLAG_FLUSHURL_ONDELETE = 0x2;
// File not found.
const int ERROR_FILE_NOT_FOUND = 0x2;
// No more items have been found.
const int ERROR_NO_MORE_ITEMS = 259;
// Pointer to a GROUPID variable
long groupId = 0;

// Local variables
int cacheEntryInfoBufferSizeInitial = 0;
int cacheEntryInfoBufferSize = 0;
IntPtr cacheEntryInfoBuffer = IntPtr.Zero;
INTERNET_CACHE_ENTRY_INFOA internetCacheEntry;
IntPtr enumHandle = IntPtr.Zero;
bool returnValue = false;

// Delete the groups first.
// Groups may not always exist on the system.
// For more information, visit the following Microsoft Web site:
// http://msdn.microsoft.com/library/?url=/workshop/networking/wininet/overview/cache.asp
// By default, a URL does not belong to any group. Therefore, that cache may become
// empty even when the CacheGroup APIs are not used because the existing URL does not belong to any group.
enumHandle = FindFirstUrlCacheGroup(0, CACHEGROUP_SEARCH_ALL, IntPtr.Zero, 0, ref groupId, IntPtr.Zero);
// If there are no items in the Cache, you are finished.
if (enumHandle != IntPtr.Zero && ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error())
return;

// Loop through Cache Group, and then delete entries.
while(true)
{
// Delete a particular Cache Group.
returnValue = DeleteUrlCacheGroup(groupId, CACHEGROUP_FLAG_FLUSHURL_ONDELETE, IntPtr.Zero);
if (!returnValue && ERROR_FILE_NOT_FOUND == Marshal.GetLastWin32Error())
{
returnValue = FindNextUrlCacheGroup(enumHandle, ref groupId, IntPtr.Zero);
}

if (!returnValue && (ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error() || ERROR_FILE_NOT_FOUND == Marshal.GetLastWin32Error()))
break;
}

// Start to delete URLs that do not belong to any group.
enumHandle = FindFirstUrlCacheEntry(null, IntPtr.Zero, ref cacheEntryInfoBufferSizeInitial);
if (enumHandle == IntPtr.Zero && ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error())
return;

cacheEntryInfoBufferSize = cacheEntryInfoBufferSizeInitial;
cacheEntryInfoBuffer = Marshal.AllocHGlobal(cacheEntryInfoBufferSize);
enumHandle = FindFirstUrlCacheEntry(null, cacheEntryInfoBuffer, ref cacheEntryInfoBufferSizeInitial);

while(true)
{
internetCacheEntry = (INTERNET_CACHE_ENTRY_INFOA)Marshal.PtrToStructure(cacheEntryInfoBuffer, typeof(INTERNET_CACHE_ENTRY_INFOA));

cacheEntryInfoBufferSizeInitial = cacheEntryInfoBufferSize;
returnValue = DeleteUrlCacheEntry(internetCacheEntry.lpszSourceUrlName);
if (!returnValue)
{
returnValue = FindNextUrlCacheEntry(enumHandle, cacheEntryInfoBuffer, ref cacheEntryInfoBufferSizeInitial);
}
if (!returnValue && ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error())
{
break;
}
if (!returnValue && cacheEntryInfoBufferSizeInitial > cacheEntryInfoBufferSize)
{
cacheEntryInfoBufferSize = cacheEntryInfoBufferSizeInitial;
cacheEntryInfoBuffer = Marshal.ReAllocHGlobal(cacheEntryInfoBuffer, (IntPtr) cacheEntryInfoBufferSize);
returnValue = FindNextUrlCacheEntry(enumHandle, cacheEntryInfoBuffer, ref cacheEntryInfoBufferSizeInitial);
}
}
Marshal.FreeHGlobal(cacheEntryInfoBuffer);
}
}
}


编译,然后运行该项目。
若要确认 Internet 临时文件缓存中的已被删除,请按照下列 Microsoft Internet Explorer 中的步骤操作:
在 工具 菜单上单击 Internet 选项 。
在在 常规 选项卡上 临时 Internet 文件 区域中,单击 设置 。
单击 查看文件 。 请注意已删除的所有文件在 Internet Explorer 缓存中。  

稿件编号:3371026号    
  • zenghd
  • 卖家评价
  • 能力:38
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 09:48:37 评论:0票数:0 | 分享稿件 | 客户积分兑换礼品 下载附件 

  先看看吧  

稿件编号:3374186号    
  • qq397640359
  • 卖家评价
  • 能力:0
  • 认证: 未实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 17:12:55 评论:0票数:7 | 分享稿件 | 客户积分兑换礼品   qq:397640359  

稿件编号:3376032号    
  • zhanghairong
  • 卖家评价
  • 能力:1
  • 认证: 已通过实名认证
  • 买家评价
  • 信用:0
  • 好评:0
  • 活跃度
  • 权限: 了解金牌会员
发布者已浏览 时间:2009/06/30 22:41:50 评论:0票数:29 | 分享稿件 | 客户积分兑换礼品   请联系我发给你


致力于门户网站和系统的开发
曾供职于国内大型上市IT公司,有很好的门户站和系统设计开发经验
精通Asp.net,C#,Asp,Sql Server
熟悉C++,VB
QQ:478388849
MSN:zhanghr8@yahoo.com.cn
TEL:13015779972