If you try to open a text file in which the last character is also the first non-standard ASCII code, a COMException will be generated by method FindMimeType in MimeTypeDetection class.
For example you can create a new text file containing only the string "1°" and then try to open it.
I resolved in this way:
default:
if (IsUTF8(stream, (byte)firstByte, (byte)secondByte)) {
stream.Position = 0;
reader = new StreamReader(stream, Encoding.UTF8);
break;
} else {
byte[ buffer = new byte[BUFFER_SIZE];
int length = stream.Read(buffer, 0, BUFFER_SIZE);
if (length > 0)
return FindMimeType(buffer, 0, length);
else
return Text;
}