ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ToMemoryStream

Returns a MemoryStream from a Byte array

Source

public static MemoryStream ToMemoryStream(this Byte[] buffer)
{
   MemoryStream ms = new MemoryStream(buffer);
   ms.Position = 0;
   return ms;
}

Example

MemoryStream ms = File.ReadAllBytes(@"c:\test.txt").ToMemoryStream();

Author: Jonnidip

Submitted on: 11 jul. 2012

Language: C#

Type: System.Byte

Views: 6228