File.WriteAllText and Concurrent Accesses
问题 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 other words, what is the FileShare parameter that the File.WriteAllText method uses? It's not written in the documentation! 回答1: This is the source code from .net Framework 4.0. clearly StreamWriter is used that Uses FileShare.Read Internally. [SecuritySafeCritical] public static void WriteAllText(string path, string contents