首页 > 代码库 > Stream To String , String To Stream

Stream To String , String To Stream

        public static string StreamToString(Stream stream)        {            stream.Position = 0;            using (StreamReader stremReader = new StreamReader(stream, Encoding.UTF8))            {                return stremReader.ReadToEnd();            }        }        public static Stream StringToStream(string str)        {            byte[] strBytes = Encoding.UTF8.GetBytes(str);            return new MemoryStream(strBytes);        }