C# file read/write fileshare doesn't appear to work

后端 未结 3 848
挽巷
挽巷 2020-12-14 03:08

My question is based off of inheriting a great deal of legacy code that I can\'t do very much about. Basically, I have a device that will produce a block of data. A librar

3条回答
  •  萌比男神i
    2020-12-14 03:39

    Your consumer must specify FileShare.ReadWrite.

    By trying to open the file as FileShare.Read in the consumer you are saying "I want to open the file and let others read it at the same time" ... since there is already a writer that call fails, you have to allow concurrent writes with the reader.

提交回复
热议问题