convert string to memory stream - Memory stream is not expandable?

后端 未结 4 1601
忘掉有多难
忘掉有多难 2021-02-06 22:21

i was trying to write a string to a memory stream, but failed with the error message:

Memory stream is not expandable.

the line of code that pr

4条回答
  •  鱼传尺愫
    2021-02-06 22:44

                byte[] buffer = File.ReadAllBytes("test.xml");
                XmlDocument doc = new XmlDocument();
                using (MemoryStream output = new MemoryStream())
                {
                    using (MemoryStream ms = new MemoryStream(buffer ))
                    {
                        doc.Load(ms);
                    }
                    // Make changes to your memory stream here
                    doc.Save(output);//Output stream has the changes.
                }
    

提交回复
热议问题