MemoryStream memoryStream = new MemoryStream(); //创建其支持存储区为内存的流。 UnicodeEncoding uniEncoding = new UnicodeEncoding(); string str = "helloworld"; //要存入的字符串 byte[] string1 = uniEncoding.GetBytes(str); //转化为字节 memoryStream.Write(string1 , 0, string1 .Length); //写入流