使用 DotNetZip 时出错

Error in the use of DotNetZip

为什么会出错?

                        using Ionic.Zip;

                        ZipPath = textBox7.Text + "Instructions.zip";
                        ExtractPath = textBox7.Text;

                        var ExistingZipFile = ZipPath;
                        string TargetDirectory = ExtractPath;

                        using (ZipFile zip = ZipFile.Read(ExistingZipFile))
                        {
                            foreach (ZipEntry es in zip)
                            {
                                es.Extract(TargetDirectory, true);  // overwrite == true
                            }
                        }

The error 2 Most suitable overloaded method for "Ionic.Zip.ZipEntry.Extract (string, Ionic.Zip.ExtractExistingFileAction)" has several inadmissible arguments of E:\Install\Form1.cs 494 37 Install the Error 3 Argument "2": type conversion from "bool" to "Ionic.Zip.ExtractExistingFileAction" is impossible for E:\Install\Form1.cs 494 65 Install

如果我Uberall重写错误没有 - es.Extract(TargetDirectory);

您正在传递一个布尔值作为第二个参数。但是类型是 Ionic.Zip.ExtractExistingFileAction.

类型的枚举

请尝试将您的代码更改为:

        using (ZipFile zip = ZipFile.Read(ExistingZipFile))
        {
            foreach (ZipEntry es in zip)
            {
                es.Extract(TargetDirectory, ExtractExistingFileAction.OverwriteSilently);  // overwrite == true
            }
        }