Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用utf-8编码从xml创建zip_C#_Xml_Zip - Fatal编程技术网

C# 使用utf-8编码从xml创建zip

C# 使用utf-8编码从xml创建zip,c#,xml,zip,C#,Xml,Zip,我有一个xml字符串,我需要它来生成zip(utf-8)并将zip转换为字节数组(为什么我认为这一切都应该在memorystream中完成)。现在我有这样的想法,但我不知道下一步该怎么办 类测试 { 私有字符串Xml=”“+ "" + 等 ""; 专用字节[]XmlTest(字符串Xml) { XmlDocument xmlDoc=新的XmlDocument(); LoadXml(Xml); var buffer=newmemoryStream(); 字节[]字节; 使用(缓冲区) 使用(var

我有一个xml字符串,我需要它来生成zip(utf-8)并将zip转换为字节数组(为什么我认为这一切都应该在memorystream中完成)。现在我有这样的想法,但我不知道下一步该怎么办

类测试
{
私有字符串Xml=”“+
"" +
等
"";
专用字节[]XmlTest(字符串Xml)
{
XmlDocument xmlDoc=新的XmlDocument();
LoadXml(Xml);
var buffer=newmemoryStream();
字节[]字节;
使用(缓冲区)
使用(var存档=新ZipArchive(缓冲区、,
ZipArchiveMode.Create,true)
{
ZipArchiveEntry清单=
archive.CreateEntry(“doc.xml”);
使用(Stream st=manifest.Open())
{
使用(StreamWriter writerManifest=新StreamWriter(st))
{
writerManifest.WriteLine(xmlDoc.OuterXml);
}
}
字节=buffer.ToArray();
返回字节;
}           
}
}

为什么不使用xmlDoc.ToString()或MemoryStream。我不是舒尔how?为什么不使用xmlDoc.ToString()或MemoryStream。我不是舒尔how?