Archive for September, 2021
Converting a System.IO.Stream to String
Posted by rwezowicz in Uncategorized on September 15, 2021
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);