System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open)

这个方法打开文件的时候是以只读共享的方式打开的,但若此文件已被一个拥有写权限的进程打开的话,就无法读取了,

因此需要使用

System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open,System.IO.FileAccess.Read,FileShare.ReadWrite);

设置文件共享方式为读写,FileShare.ReadWrite。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-12-31
  • 2021-12-02
相关资源
相似解决方案