如果当前副本正在使用中,则打开文件的卷影副本
我正在尝试备份服务器上的文件,但其中一些文件正在使用中且无法打开。 相反,如果当前副本正在使用中,我想打开其卷影副本。 我怎样才能做到这一点?
作为参考,我使用的是 C# .net 3.5。
I'm trying to backup files on a server, but some of them are in use and cannot be opened. Instead, I'd like to open their shadow copy if the current copy is in use. How can I do this?
For reference, I'm using C# .net 3.5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题已经很老了,所以我的答案可能对你没有多大用处,但作为一个问答网站,也许它仍然可以帮助其他人。
我不能/不想放下整个实现,但过程是这样的:
您通过卷影服务提供程序为要读取的文件所在的驱动器创建卷影副本位于(MSDN 上有详细记录,还有一个示例客户端可以创建这些卷影副本,并且很可能足以满足您的需要)
要么创建一个持久卷影副本,要么使用“回调”机制(调用您的应用程序)
通过 UNC 路径和 CreateFile 打开所需的文件(UNC 看起来像这样:
\\?\GlobalRoot\Devices\HarddiskVolumeShadowCopyXZY\yourpath\yourfile.yourextension)
对文件执行任何您想要的操作
更多信息后将其删除:http: //technet.microsoft.com/en-us/library/cc785914%28WS.10%29.aspx
在这里: http://msdn.microsoft.com/ en-us/library/bb968832%28VS.85%29.aspx
This question is quite old already, so my answer might not be of much use to you, but SO being a Q&A site maybe it still helps someone else.
I can't / don't want to put down the entire implementation, but the procedure is goes something like this:
You create a Volume Shadow Copy via the Volume Shadow Service Provider for the drive where your file to be read is located(this is well documented on MSDN, also there is a sample client that creates these shadow copies and will most likely be sufficient for you)
Either make a persistent one, or use the "callback" mechanism (calls your app)
Open the desired file via UNC paths and CreateFile (the UNC looks something like this:
\\?\GlobalRoot\Devices\HarddiskVolumeShadowCopyXZY\yourpath\yourfile.yourextension)
Do whatever you want with the file
more info here: http://technet.microsoft.com/en-us/library/cc785914%28WS.10%29.aspx
and here: http://msdn.microsoft.com/en-us/library/bb968832%28VS.85%29.aspx
我实际上无法判断,但有以下第 9 频道的视频。
Windows Vista " 《Time Warp》:了解 Vista 的备份和恢复技术
其中有一些实现细节以及一些有关 API 结构的内容。 我相信请记住他们提到了卷影副本如何映射到文件系统中。
I cannot actually tell, but there is the following Channel 9 video.
Windows Vista "Time Warp": Understanding Vista's Backup and Restore Technologies
There are some implementation details and a bit about the API structure. And I believe to remember that they mentioned how the shadow copies are mapped into the file system.
如果您控制第一个进程,则可以指定文件句柄共享类型
If you have control of the first process you can specify file handle share type