Click here to Skip to main content
15,748,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

i have a database of songs and i want to download this song by using gridview.
In this gridview have several coloumns like as checkbox, songname.
if user select only one song by checkbox then it will be download in the user's pc.
if thay selected several check box then selected song will be convert in zip file then will be download in the user's pc.
Sergey Alexandrovich Kryukov 3-Sep-14 3:05am    
Why? usually the audio records are already well compressed. Further compressing them with ZIP algorithm does not noticeably improve compression and may only annoy some users. Better download files as is.

you can achieve it by using zipFile class

create a string array that stores the selected songs.

private void MakeZip(string fname)
            using (ZipFile zip = new ZipFile())
                string pathname = Server.MapPath("~/FileUpload/ZipFile/");
                string[] filenames = Directory.GetFiles(pathname);//here add your selected songs file path

                 foreach (string filename in filenames)

                ZipEntry e = zip.AddFile(filename,"");

more about ZipFIle Class[^]
Share this answer
Sergey Alexandrovich Kryukov 3-Sep-14 3:11am    
I up-voted this good answer with my 4. The only problem is: it requires .NET v.4.5.
For other versions of .NET, please see my Solution 2.
First please see my comment to the question and make sure you really want what you asked about.

You have several options to work with ZIP. If you use .NET v.4.5, the first choice can be this:[^].

If you use older versions of .NET, there a 3rd-party options.

  1. You can use #ziplib:[^].
  2. Another option is using SevenZipSharp, a .NET wrapper of the famous 7-Zip:[^],[^].
  3. Another option is SharpCompress, a fully native .NET library for several compression formats:[^],[^].

All three options are open-source. I would recommend to include source project in your solution.

Share this answer

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

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