Deleting a folder with a thumbs.db file in it? RRS feed

  • Question

  • Hi,

    I have the following problem removing a folder with content (for now only files - JPG images)

    When I use DeleteAsync() I get "Folder is not empty" (Note that I'm guessing, since I get the message in German)

    I removed before all the content files (for which my application declared access in the manifest).

    The folder appears now to be empty, but the exception remains the same.

    I've turned the system file filter in Explorer off and there it is : a lonely Thumbs.db in the folder.

    I tried to add a manifest file type (.db) but I never get to the StorageFile, so I'm unable to delete it.

    This seems to be a closed circle - when inside a folder a system file gets created!

    Looking forward for solutions - Thanks

    Nikolay Nikolov

    Tuesday, March 20, 2012 12:41 PM

All replies

  • Hi Nikolay,

    This will happen if some other application has a file in the directory open. Since that file is in use it can't be deleted, and since it can't be deleted the directory can't be deleted. You will see the same behavior if you try to delete the folder from a cmd window.

    In the thumbs.db case, Explorer may have it open for housekeeping: it may be trying to generate a thumbnail for one of the images in the folder, etc. I wasn't able to reproduce this locally without a contrived example, so the delete should work in normal cases. Your best bet here may be to detect the failure and come back to try again some other time. It is possible that the thumbs.db file is being used because of something your app is doing, in which case you may be able to avoid the situation by changing how the app works; however, I can't do more than guess that the app is manipulating the images in the folder in some way. You could try watching the folder and file in Process Monitor to see who is opening it and when to try to correlate that with your app's activity.


    Wednesday, March 21, 2012 3:12 AM
  • Thank you, Rob!

    When I try to delete a the folder and all its content, I first iterate all files (with access granted by manifest) and delete them awaitiing it. There are no more files in the folder than "thumbs.db", which I do not "see" programatically although I added ".db" in the manifest.

    I obviosly need a way to delete the thumbs.db file programatically:

    Process Monitor shows that DeleteAsync issues an QueryDirectory operation with detail "0: . 1: .. 2: Thumbs.db"

    (I assume the result are the files - just the one) and no (failed) try to delete the folder is listed - the operation is apparently aborted.

    I'm further sure that Windows Explorer holds thumbs.db, because "occasionally" I couldn't even delete it manually in explorer!

    I changed the behaviour of the application, it now renames a folder in "<name>.deleted" and tries to delete it on next launch.

    Even that fails (same reason)!


    Wednesday, March 21, 2012 10:59 AM