打开文件的卷影副本,如果当前副本是在使用 [英] Opening a file's Shadow Copy if the current copy is in use

查看:198
本文介绍了打开文件的卷影副本,如果当前副本是在使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想备份文件在服务器上,但其中一些正在使用,不能打开。相反,我想开自己的卷影副本,如果当前副本正在使用中。我怎样才能做到这一点?

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?

有关的参考,我使用C#.NET 3.5。

For reference, I'm using C# .net 3.5.

推荐答案

这个问题是很老了,所以我的答案可能不是多大用处给你,但SO是一个Q&放大器;一个网站也许它仍然可以帮助别人

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:

  1. 您创建一个卷影复制通过卷影服务提供程序在哪里读你的文件所在的驱动器(这是有据可查的MSDN上,也出现导致这些卷影副本和将一个样本客户端最有可能是够你用的)

  1. 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)

打开通过UNC路径和的CreateFile(联合国军司令部看起来像这样所需的文件: \\?\ GlobalRoot \设备\ HarddiskVolumeShadowCopyXZY \ yourpath \ yourfile.yourextension)

Open the desired file via UNC paths and CreateFile (the UNC looks something like this: \\?\GlobalRoot\Devices\HarddiskVolumeShadowCopyXZY\yourpath\yourfile.yourextension)

做任何你想要的文件

在这里更多的信息:<一href="http://technet.microsoft.com/en-us/library/cc785914%28WS.10%29.aspx">http://technet.microsoft.com/en-us/library/cc785914%28WS.10%29.aspx 这里:<一href="http://msdn.microsoft.com/en-us/library/bb968832%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/bb968832%28VS.85%29.aspx

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

这篇关于打开文件的卷影副本,如果当前副本是在使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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