Wednesday, September 9, 2009
The not-so-dark secret of File.WriteAllText
When you use this method using the overload with Encoding as third parameter, it writes this encoding's signature into the file. Using this method without the encoding parameter gives you a UTF-8 encoded file WITHOUT the signature. This actually helped me a lot, since I needed a UTF-8 file with signature. Though nowhere documented, this little feature saved me some hacking like this. Nice!