Click to See Complete Forum and Search --> : Can't delete Thumbnail Cache under Windows 7


patrick22
June 18th, 2009, 05:29 PM
Hi,

under Vista, i used to delete my Thumbnail Cache files :

AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db
AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db
AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db
AppData\Local\Microsoft\Windows\Explorer\thumbcache_1024.db
AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db
AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db

with the following Code:


if ( !DeleteFile( filesC.Item( i ) ) )
{
DWORD dwAttC = GetFileAttributes( filesC.Item( i ) );
dwAttC &= ~( FILE_ATTRIBUTE_READONLY );

SetFileAttributes( filesC.Item( i ), dwAttC );

DeleteFile( filesC.Item( i ) );
}


after restarting explorer.exe, those files are automatically regenerated.

Under Windows 7 this is not the case, those files are not deleted or regenerated even after restarting the system.

Am i missing something, or there is some way to notify explorer.exe to delete those files?


Thanks in advance.

Marc G
June 22nd, 2009, 07:20 AM
Run it in a debugger and check which line is giving an error and which error code. That might give you a hint what is going on.

patrick22
June 22nd, 2009, 01:39 PM
I am debugging it with VS 2008 Express Edition.

Under Vista:

-The first call to DeleteFile returns 0, and GetLastError returns ERROR_ACCESS_DENIED.
-After changing the file attribute, DeleteFile returns non-zero value(success).
-Thumbnails are regenerated automatically after restarting explorer.exe.

Under Windows 7:

-The first call to DeleteFile returns 0, and GetLastError returns ERROR_ACCESS_DENIED.
-After changing the file attribute, DeleteFile returns 0, and GetLastError returns again ERROR_ACCESS_DENIED.
-Thumbnails are not deleted or regenerated even after restarting the System.


What i want to know, why under Vista, this piece of code is working and under Windows 7 not?!