Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET/C#: Bundling Sets of Files, Zipping Them Up, and Sending Back to User thru Response
    primarykey
    data
    text
    <p>Let's say that I have a website where I'd like users to be able to download a certain group of files. There will be checkboxes and listboxes of options for users to choose from, so that they can select what parts they want to include and what they don't want to download. Then, they click the Download button and their browser downloads a zip file containing only the things they selected.</p> <p>I want to accomplish such a hypothetical situation with ASP.NET and C#. Of course, I could make zip files of all the permutations, but that would take a LOT of time. <strong>Is it somehow possible, if I have the file paths of files stored on my server, to take some of those files, zip them up (in memory or on disk and then delete it), and send the zip file to the client thru the Response?</strong></p> <p><strong>UPDATE:</strong> I just found the <a href="https://stackoverflow.com/questions/1153047/sending-zip-file-to-client-via-response-with-dotnetzip" title="yay">following question</a> and code sample thru the Related box:</p> <pre><code>private void sendToClient(Dictionary&lt;string, string&gt; reportDic) { Response.Clear(); Response.BufferOutput = false; String ReadmeText = "some text"; Response.ContentType = "application/zip"; Response.AddHeader("content-disposition", "filename=" + "filename.zip"); using (ZipFile zip = new ZipFile()) { zip.AddEntry("Readme.txt", ReadmeText); zip.Save(Response.OutputStream); } Response.Close(); } </code></pre> <p>It uses DotNetZip to zip up the file.</p> <p>Do you think this is what I'm looking for? I'm going to go read the docs of DotNetZip.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload