如何直接从磁盘复制锁定的文件并确保文件完好无损?

发布于 2024-11-14 03:38:06 字数 329 浏览 5 评论 0原文

我正在编写的应用程序需要能够复制锁定的文件。我们尝试使用卷影复制,虽然它成功复制了文件,但锁定文件的应用程序崩溃了,因为它在复制文件时无法获取锁定。

我只能相信我唯一的选择是绕过操作系统并直接从磁盘读取。问题是,如果我直接读取磁盘,我无法确定文件的完整性,如果它处于写入过程中,文件将处于损坏状态。

经过几个小时的搜索,我找到了一个实用程序,可以直接从磁盘复制文件,并使用文件系统驱动程序在复制时缓存写入,以便确保文件处于完整状态。然而,该实用程序非常昂贵,我可能需要使用 100k+ 的许可证。

有谁对如何实现我想要的目标有任何想法?

我们计划将系统限制为仅支持 NTFS 卷。

The application I am writing needs to be able to copy files that are locked. We attempted to use Volume Shadow Copy, and while it was successful in copying the file, the application that had the lock on the file crashed because it could not acquire a lock while we were copying the file.

I am left to believe that my only option is to bypass the OS and read directly from the disk. The problem is that if I read directly to the disk I cannot be sure of the integrity of the file, if it is in the middle of a write the file will be in a damaged state.

After hours of searching I was able to find one utility that copied the file directly from the disk and used a file system driver to cache writes while copying so that it could make sure that the file was in an intact state. However, that utility is extraordinarily expensive, 100k+ for the license I would likely need to use.

Does anyone have any ideas on how to accomplish what I am trying to?

We are planning on restricting the system to NTFS volumes only.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

居里长安 2024-11-21 03:38:06

我最终使用了 Napalm 编写的名为 DirectCopy 的 C 程序。它运作得相当好。

http://www.rohitab.com/discuss/主题/24252-ntfs-directcopy-method-from-napalm/

I ended up using a C program called DirectCopy written by Napalm. It works rather well.

http://www.rohitab.com/discuss/topic/24252-ntfs-directcopy-method-from-napalm/

孤君无依 2024-11-21 03:38:06

您能否获取已锁定的应用程序的进程 ID,并在执行复制时挂起其线程?像这样的 http://www.codeproject.com/KB/threads/pausep.aspx

Can you grab the process ID of the application that has a lock on it and suspend its thread while you perform the copy? Something like this http://www.codeproject.com/KB/threads/pausep.aspx

小傻瓜 2024-11-21 03:38:06

<一href="http://books.google.co.uk/books?id=fDxg1W3eT2gC&pg=PA135&lpg=PA135&dq=intercepting%20ntfs%20write&source=bl&ots=e6Z-fyBsrw&sig=NG0NINe2 081s8aTV0tpQQyQe6Iw&hl=en&ei=P9D4TaSBJsqE​​hQeYuv3zC​​w&sa=X&oi=book_result&ct=结果&resnum=3&ved=0CCIQ6AEwAjgK#v=onepage&q&f=false" rel="nofollow">这个“分层驱动程序”的描述可能有用。但我对此一无所知。

另外,如果文件被锁定,那么您可以“观看”它并等待它解锁,然后快速复制它吗?

This description of "layered drivers" might be useful. I know nothing about it though.

Also, if the file is locked then can you just 'watch' it and wait for it to be unlocked and then quickly copy it?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文