The following example shows how to open a zip C# with Example



The following example shows how to open a zip C# with Example

archive and extract all .txt files to a folder 
using System; 
using System.IO; 
using System.IO.Compression; 
namespace ConsoleApplication1 
{ 
class Program 
{ 
static void Main(string[] args) 
{ 
string zipPath = @"c:\example\start.zip"; 
string extractPath = @"c:\example\extract"; 
using (ZipArchive archive = ZipFile.OpenRead(zipPath)) 
{ 
foreach (ZipArchiveEntry entry in archive.Entries) 
{ 
if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase)) 
{ 
entry.ExtractToFile(Path.Combine(extractPath, entry.FullName)); 
} 
} 
} 
} 
} 
} 
 

path filter 
The directory to monitor, in standard or Universal Naming The type of files to watch. For example, "*.txt" watches 
Convention (UNC) notation. for changes to all text files. 

0 Comment's

Comment Form

Submit Comment