Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a directory removed by _rmdir to update immediately in Windows Explorer?

I have a Win32 program that will delete a directory if it has deleted all files in it. The directory delete succeeds and the directory is deleted but until the program exits, the directory will still be displayed in a Windows Explorer window. Attempting to open the folder in Explorer will produce a pop up error message to the effect: "Location is not available" " is not accessible. Access is denied."[OK].

Calling _unlink() for files in a folder update in an Explorer window almost immediately. Is there some way to "flush" the file system other than exiting the program. The program is typically left running for days, so having phantom folders that give errors until the program exits is not acceptable. Is there a way to do this with _unlink() or am I going to have to switch to Windows API version of the call?

like image 281
ChocoBilly Avatar asked Oct 20 '22 02:10

ChocoBilly


1 Answers

Do you hold any descriptors to that directory? Use Process Explorer to check for file handles containing its name.

Since Windows Explorer is showing the directory while the application is running, but stops showing it after it exits, the problem is likely that your application is holding a handle or file descriptor to that directory, which somehow keeps the directory from being completely deleted, or it tricks Windows Explorer into thinking it still is in the file system.

like image 85
sashoalm Avatar answered Oct 22 '22 17:10

sashoalm