I've been having an intermittent issue with files located on a network that I am trying to delete. I'll run into an exception where it says the file cannot be deleted because it's in use by another application.

When I try to delete it manually from the network it gives me the same error. However, when I walk 2 feet away to another computer, logged in as a different account, i'll browse to the same location and the file will not be there at all indicating that it deleted, but must be still in use from some indexing service.

A colleague mentioned something about the windows search service and how it indexes stuff. I disabled that and ended the SearchIndexer.exe process. That worked for a few times and then it started to reoccur randomly.

I can end my explorer.exe process and re-run it, then manually delete the files no problem.

It occurs when I do a Directory.Delete with recursion set to true. The majority of the time it happens with the Thumbs.db file, so it ends up not deleting the directory at all and i'm forced to end my explorer.exe and restart it in order to delete the directory.

My question is, if the file gets deleted from the network but doesn't display as deleted on my computer, how do I prevent it from getting locked in my explorer process?

Has anyone else ran into this before?