I'm trying to read a json-file, change the content and write it back.
Multiple processes are accessing the same file, so I need to lock the text file so no other thread or process can access it, read from it and write to it and unlock the file.
I tried using StreamWriter / StreamReader in various ways with no success:
You could try the sequence: Open reader, read into memory, close reader. Open writer, overwrite file, close writer.
You could write out to a temp file and then rename it. It would be impossible to read a file and (over)write it out at the same time.