Ejemplo n.º 1
0
 public static void Compress(Stream stream, FileStreamInfo file, params FileStreamInfo[] files)
 {
     List<FileStreamInfo> lst = new List<FileStreamInfo>();
     lst.Add(file);
     lst.AddRange(files);
     Compress(stream, lst.ToArray());
 }
Ejemplo n.º 2
0
        public static void Compress(Stream stream, FileStreamInfo[] files)
        {
            ZipOutputStream zipStream = new ZipOutputStream(stream);
            zipStream.SetLevel(6);

            for (int i = 0; i < files.Length; i++)
            {
                FileStreamInfo file = files[i];
                byte[] buffer = file.ToArray();

                ZipEntry entryPart = new ZipEntry(file.Name);
                entryPart.DateTime = DateTime.Now;
                entryPart.Size = buffer.Length;

                zipStream.PutNextEntry(entryPart);
                zipStream.Write(buffer, 0, buffer.Length);
            }
            zipStream.Finish();
        }