[英]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. 我有一个Win32程序,如果删除了目录中的所有文件,将删除该目录。 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. 目录删除成功并删除目录,但在程序退出之前,该目录仍将显示在Windows资源管理器窗口中。 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. 几乎立即在资源管理器窗口中为文件夹更新中的文件调用_unlink()。 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? 有没有办法用_unlink()执行此操作,或者我将不得不切换到Windows API版本的调用?
Do you hold any descriptors to that directory? 你对该目录持有任何描述符吗? Use Process Explorer to check for file handles containing its name. 使用Process Explorer检查包含其名称的文件句柄。
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. 由于Windows资源管理器在应用程序运行时显示该目录,但在退出后停止显示该目录,因此问题很可能是您的应用程序正在将该句柄或文件描述符保存到该目录,这会以某种方式阻止该目录被完全删除,或者它让Windows资源管理器认为它仍然在文件系统中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.