I need to get the encoding type of a csv file and how can i do this in c#.net..
My code to avoid Byte Order Mapping(BMO) added during UTF8 encoding is as follows:
public static void SaveAsUTF8WithoutByteOrderMark(string fileName, Encoding encoding)
{
if (fileName == null)
throw new ArgumentNullException("fileName");
if (encoding == null)
{
encoding = Encoding.Default;
}
File.WriteAllText(fileName, File.ReadAllText(fileName, encoding), new UTF8Encoding(false));
}
But any one please tell me how i can find the encoding of a csv file in C#.net..
There’s an example of a simple class that will detect the encoding here (which doesn’t just check for
BOM).