I am writing a messaging app in C# that runs on a shared file server on a network. The program works by multiple users running the program which accesses a file that is shared between the multiple computers. Hence, I need to use the StreamReader/StreamWriter to access the file with multiple programs at once (EDIT: I now know this isn’t a good way to do it, but it’s what I needed at the time). So how may I access a single file with multiple programs without getting errors about the file being in use?
Share
I think your approach will lead to problems in the future. I’d consider leveraging Redis pub/sub if I were you.
But, since you asked… (I wrote a blog post on this: http://procbits.com/2011/02/18/streamwriter-share-read-access-in-another-process/ )
Generator of chat data:
Somewhere else in your app or another app…
Readers of chat data: