I need to have two Unity instances open simultaneously (not executables, but both in Editor mode), one keeps writing data to a local text file, while the other keeps reading content in that text file.
Mainly I am using FileStream to do StreamWriter and StreamReader. But I keep getting this error: “IOException: Sharing violation on path: C:\myfolder\position.txt”. Obviously the two Unity instances are fighting for file access permission – if one is reading (writing), the other can’t write (read).
I searched for some solutions online, most of them are about having one same script that has both StreamWriter and StreamReader, and the script is running in one single instance of Unity. I tried to apply this solution to my two Unity instances but it didn’t work. I was still getting the same error.
Could you share some suggestions? Thanks.
(Doesn’t have to be FileStream…whatever works for this concurrent reading/writing on two Unity instances.)