As found in: http://www.personalmicrocos... public static Encoding GetFileEncoding(String FileName) { Encoding Result = null; FileInfo FI = new FileInfo(FileName); FileStream FS = null; try { FS = FI.OpenRead(); Encoding[] UnicodeEncodings = { Encoding.BigEndianUnicode, Encoding.Unicode, Encoding.UTF8 }; for(int i = 0; Result == null && i < UnicodeEncodings.Length; i++) { FS.Position = 0; byte[] Preamble = UnicodeEncodings[i].GetPrea... bool PreamblesAreEqual...
In this category I will post some "creative" solutions to problems. (Code changed to protect the inocents). // The WTF way int myInt = Int32.Parse(myDataTable.Row... + ""); // The correct way int myInt = myDataTable.Rows.Count;