Reputation: 7708
I'm using this method to write to a MemoryStream object, which is subsequently stored a binary in SQL. It is being used to read in .HTML files from the file system on Windows.
How do I know which type of encoding this data is being read in as? Thanks.
Upvotes: 4
Views: 4470
Reputation: 887459
FileInfo.OpenRead
returns a raw stream that does not use any encoding (since it returns bytes, not characters).
Encodings are used to convert raw bytes into Unicode characters.
In .Net, encodings are used by the StreamReader
and StreamWriter
classes, which work with strings instead of bytes.
Upvotes: 1
Reputation: 29632
None, because it opens a binary stream. When you e.g. wrap stream into a StreamReader
, that's the moment you choose the encoding. The FileStream
itself as returned by the OpenRead
method is not text based and thus does not have an encoding.
Upvotes: 10