Suppose I\'m writing a very long string to a file using File.WriteAllText, and another thread or process is trying to read the same file. Would it throw any exception? In ot
MSDN doesn't document which sharing mode is used.
You could look at the source code (either published or via a disassembler), or look at the option at runtime (eg. using Process Monitor and then translating the WIn32 API flags into FileShare value).
But as it isn't documented a patch or new version could change it.
Alternatively if it matters open the file yourself using one of the FileStream overloads that takes a FileShare
parameter, open a StreamWriter over this and then write the text.
Would it throw any exception?
Yes. If the file is open already with an incompatible sharing mode the open will fail.