Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


ASP.NET c# code: Zipping files and saving files to client local computer  with save file dialog box

Posted on 2013-11-30
Medium Priority
Last Modified: 2013-12-02
The following code saves the zipped file in the server.
I have Ionic.Zip.dll in the bin folder
using System.IO;
using Ionic.Zip;
protected void btnzip_Click(object sender, EventArgs e)
string path = Server.MapPath("~/App_Info_Folders/" + lblattfld.Text + "/");
        string[] filenames = Directory.GetFiles(path);

        using (ZipFile zip = new ZipFile())
            zip.AddFiles(filenames, "files");

            lblmessage.Text = "ZIP File Created Successfully";

I want the code to be modified in such a way that the zipped file is directly saved on the client local computer through save file dialog box.
Question by:Srinivas Mantha
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

by:Mohit Vijay
ID: 39687872
What is meaning of Directly save? If you want to save on client computer without informing user, it will not be possible, because of security issues in web application. Can be done with Windows Application only.

Expert Comment

ID: 39687878
Please check this link;

Client download samples

Author Comment

by:Srinivas Mantha
ID: 39688083
To VJsoft:
I mean save directly (without saving on server) on client computer of course with knowledge of user. Save file dialog box permits user to save on any location on the client user computer. I do not think the code is difficult at all. I am not able recall now.
XGIS: client download samples are not helpful. I had seen them before approaching Experts-Exhange.
LVL 27

Accepted Solution

Chinmay Patel earned 1200 total points
ID: 39689216


Open in new window

put this code

string strURL=Server.MapPath("~/samplefiles.zip");
          WebClient req=new WebClient();
          HttpResponse response = HttpContext.Current.Response;
          response.Buffer= true;
          response.AddHeader("Content-Disposition","attachment;filename=\"" + Server.MapPath(strURL) + "\"");
          byte[] data=req.DownloadData(Server.MapPath(strURL));

Open in new window

Source: http://venkateswarlu.co.in/DotNet/download_file.aspx

Author Closing Comment

by:Srinivas Mantha
ID: 39689714
Apt and complete solution. The code is working to my expectations. Only a small correction is required
Intead of
string strURL=Server.MapPath("~/samplefiles.zip");
we need to use
string strURL = "~/samplefiles.zip";

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question