如何修改zip文件中的文件属性?

How to modify file attribute in zip file?

使用 SharpZipLib,我将文件添加到现有的 zip 文件中:

        using (ZipFile zf = new ZipFile(zipFile)) {
            zf.BeginUpdate();
            foreach (FileInfo fileInfo in fileInfos) {
                string name = fileInfo.FullName.Substring(rootDirectory.Length);
                FileAttributes attributes = fileInfo.Attributes;
                if (clearArchiveAttribute) attributes &= ~FileAttributes.Archive;

                zf.Add(fileInfo.FullName, name);
//TODO: Modify file attribute?
            }
            zf.CommitUpdate();
            zf.Close();
        }

现在的任务是清除 Archive 文件属性。
但不幸的是,我发现这只有在使用 ZipOutputStream 创建新的 zip 文件并设置 ExternalFileAttributes:

时才有可能
            // ...
            ZipEntry entry = new ZipEntry(name);
            entry.ExternalFileAttributes = (int)attributes;
            // ...

有没有办法添加文件修改文件属性?

DotNetZip 可以吗?

因为有SharpZipLib的源码,我又自己加了一个重载的ZipFile.Add

    public void Add(string fileName, string entryName, int attributes) {
        if (fileName == null) {
            throw new ArgumentNullException("fileName");
        }

        if (entryName == null) {
            throw new ArgumentNullException("entryName");
        }

        CheckUpdating();
        ZipEntry entry = EntryFactory.MakeFileEntry(entryName);
        entry.ExternalFileAttributes = attributes;
        AddUpdate(new ZipUpdate(fileName, entry));
    }

效果很好...