I get a FileStream(filename,FileMode.Open,FileAccess.Read,FileShare.ReadWrite)
and then a StreamReader(stream,true)
.
Is there a way I can check if the stream started with a UTF8 BOM? I am noticing that files without the BOM are read as UTF8 by the StreamReader.
How can I tell them apart?
if (preamble.Where((p, i) => bytes.Length > i && p != bytes[i]).Any())
or whatever floats your boat. – Afterthought