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

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.
Posted
Comments
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.
—SA

you can achieve it by using zipFile class

create a string array that stores the selected songs.

C#
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,"");
                  }
                zip.Save(Server.MapPath("~/Zips/abc.zip"));
            }
        }



more about ZipFIle Class
http://msdn.microsoft.com/en-us/library/system.io.compression.zipfile(v=vs.110).aspx[^]
 
Share this answer
 
Comments
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.
—SA
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: http://msdn.microsoft.com/en-us/library/system.io.compression.zipfile%28v=vs.110%29.aspx[^].

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

  1. You can use #ziplib:
    http://www.icsharpcode.net/opensource/sharpziplib/[^].
  2. Another option is using SevenZipSharp, a .NET wrapper of the famous 7-Zip:
    http://en.wikipedia.org/wiki/7-Zip[^],
    http://sevenzipsharp.codeplex.com/[^].
  3. Another option is SharpCompress, a fully native .NET library for several compression formats:
    http://sharpcompress.codeplex.com[^],
    https://github.com/adamhathcock/sharpcompress[^].


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

—SA
 
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