ASP.NET C# zipping files on server very slow -
i need 100 files form database, zip them , download them. goes slow. wrong?
foreach (gridviewrow row in grdreport2.rows) { checkbox chkboxrows = (checkbox)row.findcontrol("chkemp1"); if (chkboxrows.checked == true) { mysqlcommand sqlcommand = new mysqlcommand(); try { string chave = row.cells[2].text; sqlcommand.commandtype = commandtype.text; sqlcommand.connection = cnn; sqlcommand.commandtext = "select xml cte chcte = '" + chave + "'"; dynamic k = sqlcommand.executereader(); if (k.read() == true) { string xml = k["xml"]; system.io.file.writealltext(zippath + "\\" + chave + "-proccte.xml", xml); oneisdone = true; } k.close(); } catch (exception ex) { string = ex.message; } sqlcommand.dispose(); sqlcommand = null; } } if (oneisdone) { try { zipfile.createfromdirectory(zippath, system.io.path.gettemppath() + t + "nfe.zip", compressionlevel.optimal, false); response.appendheader("content-disposition", "attachment; filename=" + lblclient.text + " " + cbtipo.selecteditem.text + txtfrom.text.replace("//", "-") + "|" + txtto.text.replace("//", "-") + ".zip"); response.transmitfile(system.io.path.gettemppath() + t + "nfe.zip"); response.contenttype = "application/zip"; response.flush(); } catch { } response.end(); } }
Comments
Post a Comment