用WebBrowser打开网页后,然后提取里面图片链链接,然后用WebClient保存,怎样直接从缓存读取图片的,不必再次下载?

解决方案 »

  1.   

    http://www.dotnetspider.com/qa/Question16777.aspx
    How to access Temporary Internet Files to get a file 
    http://www.codeproject.com/csharp/ponta.asp
      

  2.   

    ref:
    http://www.codeproject.com/csharp/WebCacheTool.asp
      

  3.   

    参考
    http://www.codeproject.com/csharp/WebCacheTool.asp?df=100&forumid=272203&exp=0&select=1416696
      

  4.   

    [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]   
    public struct INTERNET_CACHE_ENTRY_INFO   
    {  
    public int dwStructSize;    
    public IntPtr lpszSourceUrlName;    
    public IntPtr lpszLocalFileName;    
    public int CacheEntryType;    
    public int dwUseCount;    
    public int dwHitRate;    
    public int dwSizeLow;    
    public int dwSizeHigh;    
    public FILETIME LastModifiedTime;    
    public FILETIME ExpireTime;    
    public FILETIME LastAccessTime;    
    public FILETIME LastSyncTime;    
    public IntPtr lpHeaderInfo;    
    public int dwHeaderInfoSize;    
    public IntPtr lpszFileExtension;    
    public int dwExemptDelta;   
    } [DllImport("wininet.dll", SetLastError=true, CharSet=CharSet.Auto)]  
    public static extern IntPtr FindFirstUrlCacheEntry([MarshalAs(UnmanagedType.LPTStr)] string UrlSearchPattern, IntPtr lpFirstCacheEntryInfo, ref int lpdwFirstCacheEntryInfoBufferSize);  [DllImport("wininet.dll", SetLastError=true, CharSet=CharSet.Auto)]   
    public static extern bool GetUrlCacheEntryInfo([MarshalAs(UnmanagedType.LPTStr)] string lpszUrlName,   IntPtr lpCacheEntryInfo,   ref int lpdwCacheEntryInfoBufferSize   );

    //获取url对应cache文件
    public static string GetCatchFileName(string url)
    {
    int nNeeded = 0;
    FindFirstUrlCacheEntry(null, IntPtr.Zero, ref nNeeded);
    IntPtr buf = Marshal.AllocHGlobal(nNeeded);
    try
    {
    GetUrlCacheEntryInfo(url, buf, ref nNeeded);
    INTERNET_CACHE_ENTRY_INFO CacheItem = (INTERNET_CACHE_ENTRY_INFO)Marshal.PtrToStructure(buf, typeof(INTERNET_CACHE_ENTRY_INFO));
    return Marshal.PtrToStringAuto(CacheItem.lpszLocalFileName);
    }
    finally
    {
    Marshal.FreeHGlobal(buf);
    }
    }
      

  5.   

    先多谢net_lover,Knight94,lookfeng,fengyeng
    先看看资料。
      

  6.   

    http://www.codeproject.com/csharp/WebCacheTool.asp