如何复制锁定的文件 [英] How to copy a locked file

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

问题描述

我在VB.NET中创建了一个简单的脚本,它将文件复制到某个目的地。但不幸的是,只要文件当前由其他用户打开,我的备份就会失败。



他们的操作系统是Windows XP
我创建了我的应用程序Visual Studio 2008.



请帮助...

谢谢



我尝试了什么:



在线搜索可能的解决方案

i created a simple script in VB.NET which copies a file to a certain destination. But unfortunately my backup fails whenever the file is currently open by other user.

their OS is Windows XP
and i created my application using Visual Studio 2008.

Please please help...
thanks

What I have tried:

search for possible solution online

推荐答案

如果文件被锁定,则在正常情况下无法访问它。

您可以: Jim Scott的编码博客如何打开C#中使用的文件? [ ^ ]但我怀疑它将取决于原始文件的打开模式 - 如果它被独占锁定写入,那么它可能会失败。

替代方案是重型:卷影复制服务(VSS)

这可能会有所帮助: GitHub - alphaleonis / AlphaVSS:AlphaVSS是在MIT许可下发布的.NET类库,为卷影复制服务(也称为VSS)提供托管API。 [ ^ ]但不要指望它很简单。
If a file is locked, you can't access it under normal conditions.
It's possible that you can: Jim Scott's Coding Blog | How do I open a file that is in use in C#?[^] but I suspect it's going to depend on what mode the original file was opened for - if it's exclusive locked for writing then it may fail.
The alternative is heavy duty: Volume Shadow Copy Service (VSS)
This may help: GitHub - alphaleonis/AlphaVSS: AlphaVSS is a .NET class library released under the MIT license providing a managed API for the Volume Shadow Copy Service also known as VSS.[^] but don't expect it to be simple.


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

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