CSharp examples for File IO:MemoryStream
Read MemoryStream using StreamReader
using System;//from ww w . java2 s . com using System.IO; using System.Text; public class Program { public static void Main(string[] args) { string data = "test/ntest/ntest/n"; // \n equiv to 2 bytes, so 18 bytes. Console.WriteLine("Original data:\n{0}", data); byte[] buffer = new byte[data.Length + 20]; MemoryStream ms = new MemoryStream(buffer); StreamReader reader = new StreamReader(ms); string afterRead = reader.ReadToEnd(); Console.WriteLine("Write the data read from the stream as a string:\n{0}", afterRead); } }