Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
try
{
    sourcePath=http://192.168.10.119:8010/imgs/
    string[] files = System.IO.Directory.GetFiles(sourcePath);
    using (ZipFile zip = new ZipFile())
    {
        foreach (string s in files)
        {
            string fileName = System.IO.Path.GetFileName(s);
            //string filePath = Server.MapPath("~/SampleFiles/" + fileName);
            zip.AddFile(s, "files");
        }
        //string destFile = System.IO.Path.Combine(targetPath, fileName);
        //System.IO.File.Copy(s, destFile, true);
        //string fld = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        //Response.Write("<script>alert(" + fld + ")</script>");
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=" + MediaReference + ".zip");
        Response.ContentType = "application/zip";
        zip.Save(Response.OutputStream);
        Response.End();
    }
    RegisterStartupScript("DownloadError", "<script>alert('Folder downloaded successfully.')</script>");
}
catch(Exception ex)
{
}
Posted
Comments
AnkitGoel.com 10-Jun-14 2:40am    
Can you explain the code? and, share the filename being built?
@p@richit 10-Jun-14 2:56am    
in imgs folders there are 5 images which is download into a zip format .
Richard MacCutchan 10-Jun-14 3:35am    
Are you able to read that path in Windows Explorer?
@p@richit 10-Jun-14 4:18am    
no its a static path http://192.168.10.119:81/imgs/ of our sever and in the line
string file-name = System.IO.Path.GetFileName(s); says error : file uri not supported
Richard MacCutchan 10-Jun-14 4:19am    
Well, the error message is telling you all you need to know. Change it to a valid file path and see what happens.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900