Reputation: 379
What I want to do is unzip file into an existing directory and overwrite older file if it exists.
I am using this command to unzip file:
ZipFile.ExtractToDirectory(path + file_name_zip, path);
Upvotes: 3
Views: 7027
Reputation: 11063
Use ZipFileExtensions.ExtractToFile
Extracts an entry in the zip archive to a file, and optionally overwrites an existing file that has the same name.
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
{
entry.ExtractToFile(Path.Combine(extractPath, entry.FullName), true);
}
}
Upvotes: 4