IOException: The process cannot access the file 'file path' because it is being used by another process

前端 未结 10 2053
陌清茗
陌清茗 2020-11-22 00:13

I have some code and when it executes, it throws a IOException, saying that

The process cannot access the file \'filename\' because it

10条回答
  •  被撕碎了的回忆
    2020-11-22 00:37

    I'm using FileStream and having same issue.. When ever Two request try to read same file it throw this exception.

    solution use FileShare

    using FileStream fs = System.IO.File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
    

    I'm Just Reading a file concurrently FileShare.Read solve my issue.

提交回复
热议问题