Как распаковать один файл из zip-архива в памяти? |
Разработка на C# под linux
class ZipArchive, from System.IO.Compression.dll |
using (ZipArchive archive = new ZipArchive(postedZipStream)) { foreach (ZipArchiveEntry entry in archive.Entries) { var stream = entry.Open(); //Do awesome stream stuff!! } }
string metaDataContents; using (var zipStream = new FileStream(@"C:\OB10LinuxShare\TEST1\Temp" + "\\"+zipFileName+".zip", FileMode.Open)) using (var archive = new ZipArchive(zipStream, ZipArchiveMode.Read)) { foreach (var entry in archive.Entries) { if (entry.Name.EndsWith(".xml")) { FileInfo metadataFileInfo = new FileInfo(entry.Name); string metadataFileName = metadataFileInfo.Name.Replace(metadataFileInfo.Extension, String.Empty); if (String.Compare(zipFileName, metadataFileName, true) == 0) { using (var stream = entry.Open()) using (var reader = new StreamReader(stream)) { metaDataContents = reader.ReadToEnd(); clientProcessLogWriter.WriteToLog(LogWriter.LogLevel.DEBUG, "metaDataContents : " + metaDataContents); } } } } }