标签:byte blog span 位置 stack count com stream log
1 MemoryStream ms = new MemoryStream(); 2 StreamWriter sw = new StreamWriter(ms, Encoding.Default);
sw.AutoFlush = true; 3 sw.WriterLine("....."); 4 . 5 . 6 . 7 byte[] buff = new byte[1024]; 8 int count = ms.Read(buff, 0, 1024);
count 始終為0,buff里也讀不到數據。
在 stackoverflow.com 查到得知讀取流前,
要把流的當前位置設為0, ms.Position = 0;
問題解決。
StreamWriter寫入MemoryStream 讀不到數據
标签:byte blog span 位置 stack count com stream log
原文地址:http://www.cnblogs.com/fei001/p/6687050.html