我可以简单地“阅读”一个正在使用的文件吗? [英] Can I simply 'read' a file that is in use?

查看:111
本文介绍了我可以简单地“阅读”一个正在使用的文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用StreamReader来读取一个文件,但它始终被另一个进程使用,所以我收到这个错误:


进程无法访问文件
'\arfjwknasgmed17\C $ \FLAG
CONDITION\CP-ARFJN-FLAG.XLS',因为
它正被其他进程使用。


有没有办法可以阅读这个没有复制?或者是我唯一的选择?

解决方案

只有打开文件的程序首先指定了读共享权限,才能读取文件在该文件。



如果该文件确实没有读共享权限,那么您将无法将其复制在第一位。



如果您指定的共享权与已打开该文件的程序的共享权冲突,您可能无法访问该文件。例如,如果已经打开它的程序没有授予写入权限,则不能授予写访问权。



如果首先打开文件的程序支持卷影复制(VSS),您还可以使用VSS访问该文件。



有商业软件驱动程序允许您访问这些文件,即使它们在使用中。您以前能够通过St-Bernards获取Open File Manager,您还可以使用文件访问管理器(FAM) 通过VisionWorks解决方案公司这些驱动程序通常用于备份软件公司以包含在他们的产品中。



VSS通过告诉程序,具有文件已经打开,另一个程序想要从文件中读取。 VSS然后执行该文件的副本,并允许您从该副本中读取。 VSS不适用于旧版应用程序。



FAM通过指定可以访问专用打开和锁定的应用程序的允许列表,透明地用于旧版和非遗留程序文件。只有此列表中的程序才能访问这些文件。当文件被打开时,它进入高速缓存模式,以便您可以获取文件的副本,就像文件的备份/打开一样。在这一点上,最初打开文件的程序实际上看到该文件,而允许的列表中的第二个程序看到该文件是在文件打开/备份时发生的。这样可确保文件的一致性。


I am trying to use a StreamReader to read a file, but it is always in use by another process so I get this error:

The process cannot access the file '\arfjwknasgmed17\C$\FLAG CONDITION\CP-ARFJN-FLAG.XLS' because it is being used by another process.

Is there a way I can read this without copying it? Or is that my only option?

解决方案

You can read the file only if the program that opened the file first specified read sharing rights on that file.

If the file does indeed have no read sharing rights though, you wouldn't be able to copy it in the first place.

You may not be able to access a file if you are specifying a sharing right that conflicts with the sharing right of a program that already has the file opened. For example you can't grant write access if the program that already has it opened isn't granting write access.

If the program that opened the file in the first place supports Volume Shadow Copy (VSS), you can also use VSS to gain access to the file.

There are commercial software drivers that allow you to access such files, even when they are in use. You used to be able to get Open File Manager by St-Bernards, and you can also use File Access Manager (FAM) by VisionWorks Solutions Inc. These drivers are typically OEM'ed to backup software companies for inclusion in their products.

VSS works by telling the program that has the file opened already that another program would like to read from the file. VSS then does a copy of the file and lets you read from this copy. VSS does not work for legacy applications.

FAM transparently works for legacy and non-legacy programs alike by specifying an 'allowed list' of applications that can access exclusively opened and locked files. Only programs in this list are allowed access to these files. When a file is being opened, it goes into cache mode so that you will obtain a copy of the file as it was when the 'backup/open' of the file started. At this point the program that originally opened the file sees the file as it actually is, and the second program in the allowed list, sees the file as it was when the 'open/backup' of the file happened. This ensures consistency of the file.

这篇关于我可以简单地“阅读”一个正在使用的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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