I am developing a multi-threaded application. I am somewhere in my code:
File.Delete(sidetapedata); File.Move(sidetapedata2, sidetapedata); //sidetapedata and sidetapedata2 are two file paths that correspond to sidetapedata.txt and sidetaptdata2.txt in some directory.
The second line sometimes works fine at other times, it throws an IOException :
Cannot create a file when that file already exists.
There is another stream that accesses the sidetapedata file, but that only reads this file, does not perform write operations. i am using locks to protect race conditions. I don’t know why this is happening.
UPDATE : even when the visual C # debugger shows me this exception, looking at the directory containing these files, I see that there is no sidetapedata.txt file, but there is a sidetapedata2.txt file!
UPDATE2 . In addition, this behavior only occurs when sidetapedata.txt and sidetapedata2.txt are empty
source share