简体   繁体   English

如何让_rmdir删除目录以在Windows资源管理器中立即更新?

[英]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.

相关问题 如何以编程方式获取 Windows 命令行或 Windows 资源管理器的当前目录? - How to programmatically get current directory of a Windows command line or Windows explorer? C++ 如何使用 _rmdir 删除文件? - C++ How do I delete files with _rmdir? 如何检测Windows资源管理器是否显示给定文件夹? - How do I detect if Windows Explorer is displaying a given folder? Windows资源管理器目录作为捆绑 - Windows Explorer directory as bundle 如何检查用户(Windows 资源管理器)在 C++ 中打开的特定目录 - How I can check is specific directory opened by a user (Windows Explorer) in c++ 如何在Windows资源管理器中获取窗口的完整路径 - How to get full path of a window in Windows Explorer 如何以与我在Windows资源管理器中“发送到邮件收件人”相同的方式以编程方式发送电子邮件? - How do I programmatically send an email in the same way that I can “Send To Mail Recipient” in Windows Explorer? 如何获得C ++ Windows服务的安装目录? - How can I get the installed directory for a C++ Windows Service? 如何使用RestartManager通过Windows Installer自定义操作重新启动explorer.exe? - How do I use RestartManager to restart explorer.exe with Windows Installer custom action? 如何获取窗口中的显示数量? - How do I get the number of displays in windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM