Archive for September, 2021

Converting a System.IO.Stream to String

This is a piece of code I have needed a bunch recently … found originally at StackOverflow

byte[] bytes = new byte[content.Stream.Length];
content.Stream.Position = 0;
content.Stream.Read(bytes, 0, (int)content.Stream.Length);
string data = Encoding.UTF8.GetString(bytes);

Leave a comment