I don't get any errors at run time, but when I try to open the file I downloaded from database I get error message: The compressed(zipped) folder is invalid or corrupted, now if I save output in a zip file, and than serialize the file to database all is well, and that is just what I did, but it's not exactly pretty code.
PS. You asked have I looked at the data to see whats wrong.. That is beyond my level of expertise, I don't really know all that much about file formats etc.(If you have time or inclination to take a look at the file I'll be happy to send it and very grateful for your assistance) Here is the modified code that works:
if (progDir.Exists)
{
FileInfo[ flist = progDir.GetFiles();
DateTime vreme;
if (File.Exists("C:\\servis\\win\\bamv\\print.zip")) File.Delete("C:\\servis\\win\\bamv\\print.zip");
ZipOutputStream zipOS = new ZipOutputStream(File.Create("C:\\servis\\win\\bamv\\print.zip"));
zipOS.SetLevel(9);
zipOS.UseZip64 = 0;
ZipEntry zipEntryPrint = new ZipEntry("print/");
zipOS.PutNextEntry(zipEntryPrint);
foreach (FileInfo f in flist)
{
ZipEntry zipEntry = new ZipEntry("print/" + f.Name);
zipOS.PutNextEntry(zipEntry);
FileStream fsp = new FileStream(f.FullName, FileMode.Open);
BinaryReader brp = new BinaryReader(fsp);
byte[ binp = brp.ReadBytes(Convert.ToInt32(fsp.Length));
zipOS.Write(binp, 0, Convert.ToInt32(fsp.Length));
fsp.Close();
brp.Close();
}
vreme = DateTime.Now;
zipOS.Finish();
zipOS.Close();
FileStream fspz = new FileStream("C:\\servis\\win\\bamv\\print.zip", FileMode.Open);
BinaryReader brpz = new BinaryReader(fspz);
byte[ binpz = brpz.ReadBytes(Convert.ToInt32(fspz.Length));
int duzina = Convert.ToInt32(fspz.Length);
and than binpz goes to database.