简体   繁体   中英

How can I write to a file that is in use by another process in C#?

How can I write to a file which is used by another process in C#?

I am able to read the file using FileShare.ReadWrite , but it only works for FileAccess.Read . Does anyone have a solution?

如果另一个进程对文件进行了写锁定,那么您将无能为力,除非您不介意关闭另一个进程的句柄或将其杀死。

您应该将文件内容读取到单独的Stream中,然后释放文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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