c# - code for downloading documents in zip is not working -
i have written method download files in zip folder. after downloading when opening file it's giving error-"an attempt made move pointer before beginning of file." using ionic zip. code is-
protected void zipdownload() { var list = db.documents.where(u => u.userid == (int)session["usrid"]).select(u => new { u.doc, u.docname, u.doctype }); zipfile zip = new zipfile(); foreach (var file in list) { zip.addentry(file.docname, (byte[])file.doc.toarray()); } var zipms = new memorystream(); zip.save(zipms); byte[] filedata = zipms.getbuffer(); zipms.seek(0, seekorigin.begin); zipms.flush(); response.clear(); response.addheader("content-disposition", "attachment;filename=docs.zip "); response.contenttype = "application/zip"; response.binarywrite(filedata); response.end(); }
Comments
Post a Comment