mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
Remove an entry from a zip file #351
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fjjo23 on GitHub (Apr 26, 2019).
I need to remove an entry from a zip file and save it with a same name. I'm getting an error that the zip file is in use. As a workaround I'm saving the modified zip file with a different name, removing the original zip file and then renaming the modified zip file to the original name.
Is there any other way of doing this?
Thanks.
@adamhathcock commented on GitHub (Apr 29, 2019):
You have to be more specific, probably with code. Yes, you can do this by loading everything into memory and disposing things properly.
@fjjo23 commented on GitHub (Apr 29, 2019):
Hi,
Thank you for the respond. This is how I’m doing it right now
private void RemovePolicyFileFromPolicyContainer(string p_policyContainer, string p_policyFile)
{
using (var archive = ZipArchive.Open(p_policyContainer))
{
var entry = archive.Entries.Single(p_o => p_o.Key == p_policyFile);
}
I would like to avoid saving the modified zip file to a new file, deleting the modified file and renaming the new file to the original zip file
Thanks
From: Adam Hathcock notifications@github.com
Sent: Monday, April 29, 2019 3:06 AM
To: adamhathcock/sharpcompress sharpcompress@noreply.github.com
Cc: Fredi Jaramillo FJaramillo@Steelcloud.com; Author author@noreply.github.com
Subject: Re: [adamhathcock/sharpcompress] Remove an entry from a zip file (#449)
You have to be more specific, probably with code. Yes, you can do this by loading everything into memory and disposing things properly.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/adamhathcock/sharpcompress/issues/449#issuecomment-487471418, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE4WVF2D5Y35PHTU2KUMGE3PS2M4XANCNFSM4HIXCNYQ.
@adamhathcock commented on GitHub (Aug 20, 2019):
SaveTo a MemoryStream instead of a file