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
Open

not able to remove one entry #47

andrsbtrg opened this issue Aug 17, 2022 · 0 comments

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.

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

No branches or pull requests

1 participant