ToSic.SexyContent.ImportExport.ZipExport.AddFileToZip C# (CSharp) Method

AddFileToZip() private static method

private static AddFileToZip ( ZipOutputStream zStream, string relativePath, string file ) : void
zStream ICSharpCode.SharpZipLib.Zip.ZipOutputStream
relativePath string
file string
return void
        private static void AddFileToZip(ZipOutputStream zStream, string relativePath, string file)
        {
            var buffer = new byte[4096];
            var fileRelativePath = (relativePath.Length > 1 ? relativePath : string.Empty) + Path.GetFileName(file);
            var entry = new ZipEntry(fileRelativePath);
            entry.DateTime = DateTime.Now;
            zStream.PutNextEntry(entry);
            using (var fs = File.OpenRead(file))
            {
                int sourceBytes;
                do
                {
                    sourceBytes = fs.Read(buffer, 0, buffer.Length);
                    zStream.Write(buffer, 0, sourceBytes);

                } while (sourceBytes > 0);
            }
        }