.net - How to clear IE cache for specific site using C# not using JS or jQuery -


i want clear ie cache site using c# . having windows application uses webbrowser control login specific site. but, not storing cache using program , ie default. trying understand

https://msdn.microsoft.com/en-us/library/windows/desktop/aa384026(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa384049(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa383983(v=vs.85).aspx

but couldn't find solution out of it.

you can use class clear ie cache

public static class webbrowserhelper {     #region winapi             [dllimport("wininet",  entrypoint = "deleteurlcacheentrya",  setlasterror = true)]     public static extern bool deleteurlcacheentry(intptr lpszurlname);      [dllimport("wininet", setlasterror = true)]     public static extern bool deleteurlcachegroup(long groupid, int dwflags, intptr lpreserved);      [dllimport("wininet",  entrypoint = "findfirsturlcacheentrya",  setlasterror = true)]     public static extern intptr findfirsturlcacheentry(string lpszurlsearchpattern, intptr lpfirstcacheentryinfo, ref int lpdwfirstcacheentryinfobuffersize);      [dllimport("wininet",  setlasterror = true)]     public static extern intptr findfirsturlcachegroup(int dwflags, int dwfilter, intptr lpsearchcondition, int dwsearchcondition, ref long lpgroupid, intptr lpreserved);      [dllimport("wininet", entrypoint = "findnexturlcacheentrya",  setlasterror = true)]     public static extern bool findnexturlcacheentry(intptr hfind, intptr lpnextcacheentryinfo, ref int lpdwnextcacheentryinfobuffersize);      [dllimport("wininet",  setlasterror = true)]     public static extern bool findnexturlcachegroup(intptr hfind, ref long lpgroupid, intptr lpreserved);     #endregion      [structlayout(layoutkind.explicit)]     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 system.runtime.interopservices.comtypes.filetime lastmodifiedtime;          [fieldoffset(40)]         public system.runtime.interopservices.comtypes.filetime expiretime;          [fieldoffset(48)]         public system.runtime.interopservices.comtypes.filetime lastaccesstime;          [fieldoffset(56)]         public system.runtime.interopservices.comtypes.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;     }     public static void clearcache()     {         bool flag;         bool flag1;         long num = (long)0;         int num1 = 0;         int num2 = 0;         intptr 0 = intptr.zero;         intptr intptr = intptr.zero;         bool flag2 = false;         intptr = findfirsturlcachegroup(0, 0, intptr.zero, 0, ref num, intptr.zero);         if ((intptr == intptr.zero ? true : 259 != marshal.getlastwin32error()))         {             while (true)             {                 flag = true;                 if ((259 == marshal.getlastwin32error() ? false : 2 != marshal.getlastwin32error()))                 {                     flag2 = deleteurlcachegroup(num, 2, intptr.zero);                     if ((flag2 ? false : 2 == marshal.getlastwin32error()))                     {                         flag2 = findnexturlcachegroup(intptr, ref num, intptr.zero);                     }                     if (flag2)                     {                         flag1 = true;                     }                     else                     {                         flag1 = (259 == marshal.getlastwin32error() ? false : 2 != marshal.getlastwin32error());                     }                     if (!flag1)                     {                         break;                     }                 }                 else                 {                     break;                 }             }             intptr = findfirsturlcacheentry(null, intptr.zero, ref num1);             if ((intptr == intptr.zero ? true : 259 != marshal.getlastwin32error()))             {                 num2 = num1;                 0 = marshal.allochglobal(num2);                 intptr = findfirsturlcacheentry(null, zero, ref num1);                 while (true)                 {                     flag = true;                     internet_cache_entry_infoa structure = (internet_cache_entry_infoa)marshal.ptrtostructure(zero, typeof(internet_cache_entry_infoa));                     if (259 != marshal.getlastwin32error())                     {                         num1 = num2;                         flag2 = deleteurlcacheentry(structure.lpszsourceurlname);                         if (!flag2)                         {                             flag2 = findnexturlcacheentry(intptr, zero, ref num1);                         }                         if (!(flag2 ? true : 259 != marshal.getlastwin32error()))                         {                             break;                         }                         else if ((flag2 ? false : num1 > num2))                         {                             num2 = num1;                             0 = marshal.reallochglobal(zero, (intptr)num2);                             flag2 = findnexturlcacheentry(intptr, zero, ref num1);                         }                     }                     else                     {                         break;                     }                 }                 marshal.freehglobal(zero);             }         }     } } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -