Remember position of stream when outputting byte array

This commit is contained in:
Michael Becker 2014-06-13 14:29:42 -04:00
parent a7c047257d
commit 599a6bfe7f

View File

@ -528,9 +528,13 @@ namespace UniversalEditor
}
public static byte[] ToByteArray(this System.IO.Stream stream)
{
long oldpos = stream.Position;
byte[] array = new byte[(int)((IntPtr)stream.Length)];
stream.Position = 0L;
stream.Read(array, 0, array.Length);
stream.Position = oldpos;
return array;
}
#endregion