From: Cal Who on 31 May 2010 05:11 "Alexey Smirnov" <alexey.smirnov(a)gmail.com> wrote in message news:1183d5d7-dd04-4c49-93b8-265e233610d2(a)q13g2000vbm.googlegroups.com... On May 25, 2:52 pm, " Cal Who" <CalWhoNOS...(a)roadrunner.com> wrote: > This code works OK if the file is small but if the "do" loop has to > iterate > a second time the file is NG. > I see that you read the content into buffer of 4096 bytes. Try to use following code ZipOutputStream zipOut = new ZipOutputStream(File.Create(zipFullPath)); FileInfo fi = new FileInfo(fName); ZipEntry entry = new ZipEntry(fi.Name); FileStream sReader = File.OpenRead(fName); byte[] buff = new byte[Convert.ToInt32(sReader.Length)]; sReader.Read(buff, 0, (int) sReader.Length); entry.DateTime = fi.LastWriteTime; entry.Size = sReader.Length; sReader.Close(); zipOut.PutNextEntry(entry); zipOut.Write(buff, 0, buff.Length); zipOut.Finish(); zipOut.Close(); Hope this helps Thank you |