现在我正在使用XmlTextWriter将MemoryStream对象转换为字符串。但我不知道是否有更快的方法来串行化一个内存流到字符串。将内存流对象序列化为字符串
我遵从下面给出的序列化的代码 - http://www.eggheadcafe.com/articles/system.xml.xmlserialization.asp
编辑
流到字符串
ms.Position = 0;
using (StreamReader sr = new StreamReader(ms))
{
string content = sr.ReadToEnd();
SaveInDB(ms);
}
字符串到流
string content = GetFromContentDB();
byte[] byteArray = Encoding.ASCII.GetBytes(content);
MemoryStream ms = new MemoryStream(byteArray);
byte[] outBuf = ms.GetBuffer(); //error here
可能DUPLIC吃了[如何从一个MemoryStream字符串?](http://stackoverflow.com/questions/78181/how-do-you-get-a-string-from-a-memorystream) – 2016-03-23 12:26:21