I have a simple console application that I’m trying to delete a folder:
I got the exception of the annoying Thumbs.db
The process cannot access the file 'Thumbs.db' because it is being used by another process.
I can’t change the registry to avoid Thumbnail to process in folder
What are my options here to be able to delete the folder with everything in it?
[DllImport("kernel32.dll")] public static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, int dwFlags); public const int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4; //Usage: MoveFileEx(fileName, null, MOVEFILE_DELAY_UNTIL_REBOOT);
If you want to disable the creation of “Thumbs.db”-Files completely you can switch it off in the registry. Open the registry editor, navigate to
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer and set the value of
1. If this entry doesnt exist you simply can create it (
For Win7 Professional / Ultimate the path to the entry is
HKEY_CURRENT_USER\Software\Microsoft\ Windows\CurrentVersion\Explorer\Advanced and it’s name is