c# - How to get the files from the hierarchy of Zip Folder -
i have directory structure this: a.zip - - - 1.dat 2.dat
i want read files 1.dat , 2.dat inside directory hierarchy. able read file contentby c#, if file directly inside zip folder due inner directory structure become inaccessible.
any appreciated. in advance.
not sure how reading zip file contents without example, reading zip file contents using system.io.compression
, system.io.compression.filesystem
assemblies pretty simplistic. see following example of how read files regardless of subdirectory within zip file:
using system; using system.io.compression; namespace zipreader { class program { const string zippath = @"d:\test\test.zip"; static void main(string[] args) { using (var archive = zipfile.openread(zippath)) { foreach (var entry in archive.entries) { console.writeline(entry.fullname); } } console.readkey(); } } }
produces following output:
folder1/test1.txt folder2/test2.txt
to contents can call entry.open()
on each file returns stream
can handle need to.
Comments
Post a Comment