public ZipBuilder AddBytes(byte[] bytes, string entryName) { ZipStream.PutNextEntry(CreateEntry(entryName)); ZipStream.Write(bytes, 0, bytes.Length); ZipStream.CloseEntry(); return(this); }
public ZipBuilder AddFile(string sourcePath, string entryName) { ZipStream.PutNextEntry(CreateEntry(entryName)); StreamUtils.Copy( new FileStream(sourcePath, FileMode.Open, FileAccess.Read), ZipStream, new byte[4096]); ZipStream.CloseEntry(); return(this); }
public ZipBuilder AddTextContent(string content, string entryName) { ZipStream.PutNextEntry(CreateEntry(entryName)); // write directly to the ZipStream, but be sure to leave it open! using (var streamWriter = new StreamWriter(ZipStream, Encoding.UTF8, 4096, leaveOpen: true)) streamWriter.Write(content); ZipStream.CloseEntry(); return(this); }