Closed andyhebear closed 8 years ago
and how to change dir name in Zip? there has fast way?
You can't change names without rebuilding the entire zip file.
I could probably change something to get around recompressing but that's a lot of work for a minor use-case. You're welcome to try with a PR.
how to change ZipEntry Name? ZipArchive za=ZipArchive.Open("test.zip"); string oldName="zt/test_old.txt"; string newName="zt2/test.txt"; SharpCompress.Archive.Zip.ZipArchiveEntry findfile=null; foreach (var ze in za.Entries) { if (ze.IsDirectory) continue; if (string.Compare(ze.Key, oldName) == 0) { findfile = ze; break; } } if (findfile != null) { MemoryStream ms=GetUnCompressStream(findfile);
za.AddEntry(newName, ms,true,ms.Length,findfile.LastModifiedTime); za.RemoveEntry(findfile); findfile.Close(); }
this method is Unfriendly.
And consumes a lot of performance.