delete folder that contains thumbs.db

泪湿孤枕 提交于 2019-12-06 11:13:52

am submitting my comment as an answer because it is much more readable this way:

You can switch off a creation of these files: in Registry Editor go to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer and set NoThumbnailCache entry's value to 1.

If you don't have this entry , just create it (DWORD 32).

For Win 7 Ultimate/Professional version: HKEY_CURRENT_USER\Software\Microsoft\ Windows\CurrentVersion\Explorer\Advanced

DisableThumbnailCache (DWORD also)

To delete all already existing files create a batch file with the following content:

cd c:\

del /s /q thumbs.db

and run it as administrator

Find out who is locking

First thing you should do is finding what which process is holding a lock. You can use Unlocker to find that out.

If you can't kill, control or quit that process

You can mark files for deletion. They will get deleted at the next startup. Use PInvoke and call MoveFileEx passing null in as the destination.

You can use this for folders and files. Marking the folder for deletion should be enough.

This link has some sample code:

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, int dwFlags);

public const int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4;

MoveFileEx(filename, null, MOVEFILE_DELAY_UNTIL_REBOOT);

In my case simplest solution helped, however I am aware it is not going to help every time.

  1. Close File Explorer (this should unlock file)
  2. Open again and try to delete folder.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!