I have a byte array which I got back from a FileStream.Read and I would like to turn that into a string. I’m not 100% sure of the encoding – it’s just a file i saved to disk – how do I do the conversion? Is there a .NET class that reads the byte order mark and can figure out the encoding for me?
Share
If
File.ReadAllTextwill read the file correctly, then you have a couple of options.Instead of calling
BeginRead, you could just callFile.ReadAllTextasynchronously:Or you can create a
MemoryStreamfrom the byte array, and then use aStreamReaderon that.