Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not able to remove one entry #47

Open
andrsbtrg opened this issue Aug 17, 2022 · 0 comments · May be fixed by #60
Open

not able to remove one entry #47

andrsbtrg opened this issue Aug 17, 2022 · 0 comments · May be fixed by #60

Comments

@andrsbtrg
Copy link

hi and thanks for the very useful utility. I am using it to manipulate .idml files which are compressed folders for adobe indesign files. Extracting a file from the directory works just fine.

My goal is to replace a file in the directory. To do this I figures I should first remove the entry and then add a new one.

I am facing a problem when trying to remove an entry. After executing RemoveEntries(), the entry is still there. I can check because after running, the number of entries didn't change. However, RemoveEntries() is returning true every time.

            ZipStorer zip = ZipStorer.Open(idmlPath, FileAccess.Write);
            
            List<ZipStorer.ZipFileEntry> removeList = new List<ZipStorer.ZipFileEntry>();
            // Look for the desired file to replace
            foreach (ZipStorer.ZipFileEntry entry in zip.ReadCentralDir())
            {
                if (Path.GetFileName(entry.FilenameInZip) == Path.GetFileName(archivePath))
                {
                    removeList.Add(entry);
                }
            }
            if (removeList.Count > 0)
            {
                bool result = ZipStorer.RemoveEntries(ref zip, removeList);
            }

            zip.Close();

not sure if this is a bug or I am doing something wrong. Assuming that the ZipStorer object should be opened with write access.

@thomas694 thomas694 linked a pull request Feb 16, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant