3

我想要做的是将文件解压缩到现有目录中并覆盖旧文件(如果存在)。

我正在使用此命令解压缩文件:

ZipFile.ExtractToDirectory(path + file_name_zip, path);
4

1 回答 1

3

使用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);
                    }
                }
于 2013-10-14T09:15:54.123 回答