public static void UTF8RemoveBOM(string filepath)
{
UTF8RemoveBOM(filepath, filepath);
}
public static void UTF8RemoveBOM(string filepath, string saveAs)
{
var fs = new FileStream(filepath, FileMode.Open);
var len = fs.Length;
var buffer = new byte[len];
fs.Read(buffer, 0, (int)len);
fs.Close();
if (buffer[0] != 0xEF || buffer[1] != 0xBB || buffer[2] != 0XBF) return;
var fsw = new FileStream(saveAs, FileMode.Create, FileAccess.ReadWrite);
fsw.Write(buffer, 3, (int)len - 3);
fsw.Close();
}