Ejemplo n.º 1
0
        public ZipBuilder AddBytes(byte[] bytes, string entryName)
        {
            ZipStream.PutNextEntry(CreateEntry(entryName));

            ZipStream.Write(bytes, 0, bytes.Length);

            ZipStream.CloseEntry();
            return(this);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }