// code for Zip a multiple files// Crc32 crc = new Crc32(); string attach = AppDomain.CurrentDomain.BaseDirectory + "Documents/" + "Attachments.zip"; if (File.Exists(attach)) { File.Delete(attach); } ZipOutputStream s = new ZipOutputStream(File.Create(attach)); s.SetLevel(9); // 0 - store only to 9 - means best compression string names = hidfield.Value; string[] strNames = names.Split(','); for (int i = 0; i < strNames.Length; i++) { FileStream fs = File.OpenRead(AppDomain.CurrentDomain.BaseDirectory + "Documents/" + strNames[i]); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); ZipEntry entry = new ZipEntry(ZipEntry.CleanName("Documents/" + strNames[i])); entry.DateTime = DateTime.Now; entry.Comment = " "; entry.ZipFileIndex = i; entry.Size = fs.Length; fs.Close(); crc.Reset(); crc.Update(buffer); entry.Crc = crc.Value; s.PutNextEntry(entry); s.Write(buffer, 0, buffer.Length); } s.Finish(); s.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)