如何使用DotNetZip从zip中提取XML文件

我正在使用最新版本的DotNetZip,我有一个包含5个XML的zip文件。
我想打开zip,读取XML文件并使用XML的值设置String。
我怎样才能做到这一点?

码:

//thats my old way of doing it.But I needed the path, now I want to read from the memory string xfile = System.IO.File.ReadAllText(strNewFilePath, System.Text.Encoding.Default); using (ZipFile zip = ZipFile.Read(this.uplZip.PostedFile.InputStream)) { foreach (ZipEntry theEntry in zip) { //What should I use here, Extract ? } } 

谢谢

ZipEntry有一个Extract()重载,它提取到一个流。 (1)

在这个答案中混合如何从MemoryStream中获取字符串? ,你会得到这样的东西(完全未经测试):

 string xfile = System.IO.File.ReadAllText(strNewFilePath, System.Text.Encoding.Default); List xmlContents; using (ZipFile zip = ZipFile.Read(this.uplZip.PostedFile.InputStream)) { foreach (ZipEntry theEntry in zip) { using (var ms = new MemoryStream()) { theEntry.Extract(ms); // The StreamReader will read from the current // position of the MemoryStream which is currently // set at the end of the string we just wrote to it. // We need to set the position to 0 in order to read // from the beginning. ms.Position = 0; var sr = new StreamReader(ms); var myStr = sr.ReadToEnd(); xmlContents.Add(myStr); } } }