简体   繁体   English

c# - 如何通过网络读取由c#中的另一个进程使用/锁定的文件?

[英]How do I read a file over a network that is in use/locked by another process in c#?

Is there a way to read a locked file across a network given that you are the machine admin on the remote machine?鉴于您是远程机器上的机器管理员,有没有办法通过网络读取锁定的文件? I haven't been able to read the locked file locally, and attempting it over the network adds another layer of difficulty.我无法在本地读取锁定的文件,通过网络尝试它又增加了一层难度。

Depending on the type of lock (read only vs exclusive) it should be possible to copy the file first, then you can work with the unlocked copy.根据锁的类型(只读与独占),应该可以先复制文件,然后才能使用未锁定的副本。

You should be able to do that in a background thread.您应该能够在后台线程中执行此操作。 If you really like threading, have the file watcher start the read process once the copy is complete (although that might be overkill)如果您真的喜欢线程,请在复制完成后让文件观察器启动读取过程(尽管这可能有点过分)

There is no problems to READ the file locally or remotely if it's not locked EXCLUSIVELY or READ/WRITE.如果文件没有被独家锁定或读/写,则在本地或远程读取文件没有问题。 If the file is locked - your administrative rights will not help (even if you're GOD :-).如果文件被锁定 - 您的管理权限将无济于事(即使您是上帝:-)。 If the file is not locked fore READ (you can check it by opening it with a notepad) - you can read it locally and remotely (it doesn't matter, unless your network share is putting some extra restrictions).如果文件在 READ 之前没有被锁定(您可以通过用记事本打开它来检查它) - 您可以在本地和远程读取它(没关系,除非您的网络共享设置了一些额外的限制)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM