As you know, when we visit a website. The system caches images, animations, and so on on this site to the Temporary Internet folder.
We can access Settings\Temporary Internet files via <drives>:\documents and settings\<user>\local. But maybe we didn't realize that the files inside were actually different from the other folders and files in our system.
For example, we write a function under Vs.net to return the folder and all the files in the specified folder, but when we pass the address of the Temporary Internet folder, the system returns only one file, which is Desktop.ini (every folder has) and a hidden folder. So this proves that files in a temporary folder do not exist in the same way as normal folders and files.
In fact, Windows is a temporary file all exist in a hidden folder, this folder is we can not see, and then rely on a Index.dat index to read all the content back and forth to the user.
So how do we use the program to read the content? Because these days in helping students finish his graduation design, so studied a bit.
First, refer to a User.dll in the system folder. You can then use some of its functions to traverse the entire folder and get information about each of these files.
[DllImport ("Wininet.dll", Setlasterror=true, CharSet=CharSet.Auto)]
public static extern IntPtr Findfirsturlcacheentry (
[MarshalAs (UNMANAGEDTYPE.LPTSTR)] string lpszurlsearchpattern,
IntPtr Lpfirstcacheentryinfo,
ref int lpdwfirstcacheentryinfobuffersize);
[DllImport ("Wininet.dll", Setlasterror=true, CharSet=CharSet.Auto)]
public static extern bool FindNextUrlCacheEntry (
IntPtr Henumhandle,
IntPtr Lpnextcacheentryinfo,
ref int lpdwnextcacheentryinfobuffersize);
[DllImport ("Wininet.dll")]
public static extern bool Findcloseurlcache (
IntPtr henumhandle);
Introduce the above three functions to traverse the temporary folder and then refer to the
[DllImport ("kernel32.dll", Setlasterror=true, CharSet=CharSet.Auto)]
public static extern int FileTimeToSystemTime (
IntPtr Lpfiletime,
IntPtr lpsystemtime);
Used to convert the FILETIME time format into a string type in C # so that we can further manipulate it.
The main program is as follows:
#region Introducing DLLs
[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;
}
[StructLayout (LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct SYSTEMTIME
{
public short wyear;
public short wmonth;
public short Wdayofweek;
public short wday;
public short whour;
public short Wminute;
public short Wsecond;
public short wmilliseconds;
}
[DllImport ("kernel32.dll", Setlasterror=true, CharSet=CharSet.Auto)]
public static extern int FileTimeToSystemTime (
IntPtr Lpfiletime,
IntPtr lpsystemtime);
[DllImport ("Wininet.dll", Setlasterror=true, CharSet=CharSet.Auto)]
public static extern IntPtr Findfirsturlcacheentry (
[MarshalAs (UNMANAGEDTYPE.LPTSTR)] string lpszurlsearchpattern,
IntPtr Lpfirstcacheentryinfo,
ref int lpdwfirstcacheentryinfobuffersize);
[DllImport ("Wininet.dll", Setlasterror=true, CharSet=CharSet.Auto)]
public static extern bool FindNextUrlCacheEntry (
IntPtr Henumhandle,
IntPtr Lpnextcacheentryinfo,
ref int lpdwnextcacheentryinfobuffersize);
[DllImport ("Wininet.dll")]
public static extern bool Findcloseurlcache (
IntPtr henumhandle);
#region access to data, stored in a database
Try
{
This experience CacheItem can be
For example
string s = Marshal.ptrtostringauto (cacheitem.lpszsourceurlname);
}
Catch
{
Unusual processing
}
#endregion
string s = Marshal.ptrtostringauto (cacheitem.lpszsourceurlname);
nneeded = nbufsize;
R = FindNextUrlCacheEntry (Henum, buf, ref nneeded);
if (!r && marshal.getlastwin32error () = = Error_no_more_items)
Break
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.