Geeks With Blogs
Fórmulas e Cenas Object Reference Not Set to an Instance of an Object December 2009 Entries
How to: Open text file using the correct file encoding
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 ......

Posted On Tuesday, December 15, 2009 5:41 AM

WTF #1

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.Rows.Count + "");

// The correct way

int  myInt = myDataTable.Rows.Count;

Posted On Monday, December 14, 2009 5:37 AM

Copyright © Sglima | Powered by: GeeksWithBlogs.net | Join free