
.NET ez 2012-06-20
使用StreamReader將stream讀取出來,然後轉為string。
using System; using System.IO; namespace Test { class Program { static void Main(string[] args) { byte[] b = { 0, 1, 2, 3, 4 }; Stream stream = new MemoryStream(b); using (StreamReader reader = new StreamReader(stream)) { string str = reader.ReadToEnd(); //將stream轉為string } } } }
標籤: .NET