Hello! There is a class that extracts files from the archive with overwriting:
public static class ZipArchiveExtension { public static void ExtractToDirectory(this ZipArchive archive, string destinationDirectoryName) { foreach (ZipArchiveEntry file in archive.Entries) { string completeFileName = Path.Combine(destinationDirectoryName, file.FullName); if (file.Name == "") { Directory.CreateDirectory(Path.GetDirectoryName(completeFileName)); continue; } file.ExtractToFile(completeFileName, true); } } } Here I call him:
ZipPath = textBox4.Text + textBox5.Text + ".zip"; ExtractPath = textBox4.Text; ZipToOpen = new FileStream(ZipPath, FileMode.Open); Archive = new ZipArchive(ZipToOpen, ZipArchiveMode.Update, true, Encoding.GetEncoding("cp866")); ZipArchiveExtension.ExtractToDirectory(Archive, ExtractPath); I need something to call the method, I also specified a string array with the names of the files that should not be overwritten. Suppose I add a string array to the incoming parameters of the method and I start a string array with the names of files that should not be overwritten.
public static void ExtractToDirectory(this ZipArchive archive, string destinationDirectoryName, string[] Massive) string[] Massive = {"file1.txt", "file2.txt"}; What to do next? To loop through an array with file.Name in foreach using if, executing code if the names do not match?