public class StreamHelper { public static byte[] ToByteArray(Stream input) { if (input is MemoryStream stream) return stream.ToArray(); using (var ms = new MemoryStream()) { input.Position = 0; input.CopyTo(ms); return ms.ToArray(); } } }
518800cookie-checkC# Stream to byte[]