-1

at first I want to convert all the files which are inside one folder as .zip and then download this zipped folder using API and C#.

want to access these files from client side. Client Side I'm using AngularJS and want to download file from the server. I put different- different logic but not working.

Manu
  • 63
  • 9
  • 4
    You want to download it through a webpage? From an FTP server? Simply move a file on a local harddrive? What C# code have you already tried? All of this will help us help you better. :) – gravity May 09 '16 at 13:43
  • 3
    do it then! Ok I don't mean to be rude, you just need to start writing some code, and when you're stuck we will help you. Here is a similar solved question that can give you ideas on how to proceed : http://stackoverflow.com/questions/2670263/asp-net-download-all-files-as-zip?rq=1 – zoubida13 May 09 '16 at 13:44
  • want to access these files from client side. – Manu May 09 '16 at 13:56

2 Answers2

0

This is an exapmle of how to download a file on c#

 string filename = TextBox1.Text;
        Response.ContentType = "application/octet-stream";
        Response.AppendHeader("content-disposition", "attachment;filename=" + filename);
        Response.TransmitFile(Server.MapPath("~/Your file path/" + filename));

        Response.End();
rai nalasa
  • 849
  • 1
  • 12
  • 32
0

Try this

 public string MergeFiles(string folder)
    {
        using (ZipFile zip = new ZipFile(folder))
        {
            string[] fileEntries = Directory.GetFiles(folder);
            foreach (string f in fileEntries)
            {
                string path = Path.GetDirectoryName(f.Substring(folder.Length));
                    zip.AddFile(f, path);
            }
            zip.Save(folder + "\\files.zip");
        }
        return folder+"\\files.zip";
    }
Richard Ev
  • 52,939
  • 59
  • 191
  • 278
Ankur Shah
  • 412
  • 6
  • 16
  • I'm able to zip all the files but tell me the way I send these files to client side. Client is using AngularJS so, person can download these zipped files. – Manu May 10 '16 at 16:31
  • You can stream the zip file using Response.Content.Headers.Add("content-disposition", "attachment; filename= \"files.zip\""); context.HttpContext.Response.AddHeader("content-type", "application/zip"); – Ankur Shah May 11 '16 at 05:51