如何复制是windows下的编程锁定的文件或文件夹? [英] How do I copy a file or folder that is locked under windows programmatically?

查看:347
本文介绍了如何复制是windows下的编程锁定的文件或文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是API调用来复制当前锁定的文件。我希望能够使用的.Net,但Win32的通话将被罚款也是如此。

What are the API calls to copy a file that is currently locked. I'm hoping to be able to use .Net, but Win32 calls would be fine as well.

请随时附和约在Unix相同的功能,或任何其他操作系统。

Please feel free to chime in about the same functionality on Unix, or any other OS.

推荐答案

您可以使用VSS(卷影复制服务,没有的Visual SourceSafe)用于此目的的API。虽然功能强大,这不正是一个易于使用的API:处理备份在VSS的概述应该给你一个想法,什么是参与。

You can use the VSS (Volume Shadow Copy Service, not Visual SourceSafe) API for this purpose. While powerful, this isn't exactly an easy-to-use API: the Overview of Processing a Backup Under VSS should give you an idea what's involved.

尽管这是一个相对较新的API,为VSS .NET支持是pretty的多(和不可原谅)不存在。通过互操作不能调用大部分的API和框架文件的功能将不会与内核空间VSS使用揭露快照文件的工作。作为奖励,还有可怕的64分之32位和XP-VS-Vista的问题,从而使部署令人兴奋的,以及(在微软负责的团队应该是真的很自豪!)

Even though it's a relatively recent API, .NET support for VSS is pretty much (and inexcusably) nonexistent. You can't call most of the API through Interop, and the Framework file functions won't work with the kernel namespace VSS uses to expose the snapshotted files. As a bonus, there are horrendous 32/64-bit and XP-vs-Vista issues, making deployment exciting as well (the responsible team at Microsoft should be really proud!)

无论如何,<一个href="http://www.alphaleonis.com/2008/08/alphavss-bringing-windows-shadow-copy-service-vss-to-net/">AlphaVSS项目打算将完全VSS功能,.NET,以及看起来非常有前途的,尽管它仍然在pre-beta阶段。它可能只是做的伎俩给你,虽然,它是开源的(托管C ++)。

Anyway, the AlphaVSS project intends to bring full VSS functionality to .NET, and looks extremely promising, even though it's still in pre-beta stage. It might just do the trick for you, though, and it's open source (Managed C++).

有关如何使用Win32做事一个很好的例子,请参见 HoboCopy 。该实用程序是对自己非常有用的,和完整的C ++源代码可以从 SourceForge项目页面为好。

For a good example of how to do things using Win32, see HoboCopy. The utility is quite useful on its own, and full C++ source is available from the SourceForge project page as well.

这篇关于如何复制是windows下的编程锁定的文件或文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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