如何防止删除文件 [英] how to prevent from deleting a file

查看:62
本文介绍了如何防止删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows将阻止您删除正在运行的程序正在使用的文件.


Windows will prevent you from deleting a file that''s in use by a running program.


how can i implement in my application for a file.

推荐答案

我的建议可能是一种解决方案,而不是一种好的解决方案,但我可能只是打开一个该文件的句柄,从而从OS角度将其标记为正在使用中,直到应用程序退出后才释放该句柄.如果您试图随时在操作系统中使该文件不可删除,即使您的程序未运行,我也不确定是否可以完成.
My suggestion may be more of a hack-solution than a good one, but I would possibly just open a handle to the file, thus marking it in use from the OS perspective, and not release the handle until the application exits. If you are trying to make the file undeletable in the OS at any time, even when your program is not running, I''m not sure it can be done.


请参阅示例在约翰·西蒙斯(John Simmons)中添加了(ManfredRBihy):''部分,请在此处 [ ^ ]
See ''Example added (ManfredRBihy):'' section in John Simmons answer here[^]


这篇关于如何防止删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆