Get files from a Zip file C# with Example



Get files from a Zip file C# with Example

This example gets a listing of files from the provided zip archive binary data: 
public static Dictionary GetFiles(byte[] zippedFile) 
 

{ 
using (MemoryStream ms = new MemoryStream(zippedFile)) 
using (ZipArchive archive = new ZipArchive(ms, ZipArchiveMode.Read)) 
{ 
return archive.Entries.ToDictionary(x => x.FullName, x => ReadStream(x.Open())); 
} 
} 
private static byte[] ReadStream(Stream stream) 
{ 
using (var ms = new MemoryStream()) 
{ 
stream.CopyTo(ms); 
return ms.ToArray(); 
} 
} 

0 Comment's

Comment Form

Submit Comment