Skip to content

How to compress all files from different paths

nagendra prasad

Asked Nov 14, 2014, 9:36 PM EST1 answer
Share
LinkedInX
Hiiiii
        how to compress all the files from different paths   into a single zip file that can be  copied to another folder using C# console application
Please suggest Me

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
     string path = Server.MapPath("~/Files/");
                string[] filenames = Directory.GetFiles(path);
                using (ZipFile zip = new ZipFile())
                {
                    foreach (GridViewRow row in gv.Rows)
                    {
                        if ((row.FindControl("chkSelect") as CheckBox).Checked)
                        {
                            string filePath = (row.FindControl("lblFilePath") as Label).Text;
                            zip.AddFile(filePath, "downloadedFiles");
                        }
                    }
                    zip.Save(Server.MapPath("~/samplefiles.zip"));
    i above i have used gridview with checkbox
    u can give diff  path from here
    0