locked
create zip file in asp.net RRS feed

  • Question

  • User1772315176 posted

    hi to all,

    I am create a zip file in asp.net code using ICSharpCode.SharpZipLib.Zip ,  all thing is properly work but my problem is that when i unzip my file after download then this is use large folder's series like "c_\inetpub\wwwroot\applicationforlder\herezipfolder", if i was using two three folder for my requirments than this is vary large for view the actual file after unzip it so i wnat that the zip contain only applicationfolder name instead of "c_\inetpub\wwwroot\applicationforlder" whole path,

    if any body have any idia for remove this then help me.

    arvind

    Wednesday, July 19, 2006 5:50 AM

Answers

  • User742541801 posted

    That may work but not very dev-friendly or flexible.

    If you want a flexible, easy-to-use, reliable ZIP library for use within ASP.NET, try DotNetZip.

    http://www.codeplex.com/DotNetZip/Thread/View.aspx?ThreadId=46688

    DotNetZip does password-protected files, AES Encryption, ZIP64, Unicode filenames, Self-extracting archives, and more. It's fast and easy to use. Works on medium-trust sites. 

    It's free, open-source, works with VB, C# and any .NET language. Download it at http://dotnetzip.codeplex.com

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 12, 2009 2:26 AM
  • User742541801 posted

    In DotNetZip, the code to specify the folder structure in the ZIP file is like this:

     

    Response.Clear();
    Response.BufferOutput= false;
    string fileName= String.Format("files-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "inline; filename=\"" + archiveName + "\"");
    using (var z = new ZipFile())
    {
      // add a bunch of files, "flattening" them into a single dir in the zip
      z.AddFiles(listOfFiles, "files");
      // save directly to output stream for download to browser
      z.Save(Response.OutputStream);
    }
    Response.Close();
    

     

    DotNetZip is free to use.  Just download and go.  You can browse the class reference for DotNetZip here: http://cheeso.members.winisp.net/DotNetZipHelp/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 9:30 AM
  • User1016609979 posted

    You can also use chilkat built-in component for this purpose, go through the following link and you find a way.

     

    http://developersmania.blogspot.com/2010/06/creating-zip-file-using-cnet.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 1, 2010 5:09 PM

All replies

  • User1664555100 posted

     Hi,

    It is very simple.You can use this simple code to create a Zip file in ASP.NET with VB.

     

                    Imports System.Io

     

            Dim emptyZip As Byte() = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>        Dim oApp As Object<o:p></o:p>

            File.WriteAllBytes("c:\sijoraj.zip", emptyZip)                        'Destination Zip File Name Here

     <o:p></o:p>        oApp = CreateObject("Shell.Application")<o:p></o:p>

            oApp.Namespace("c:\sijoraj.zip").CopyHere("c:\sijoraj.JPG")           'Source File Name

            MsgBox("compressed")<o:p></o:p>

                                                                                                                                                                                                 SIJO N RAJ

                                                                                                  .NET Programmer
                                                                                                  Kerala,India
                                                                                                  sijo_raj@yahoo.com
                                                                                                 
    Wednesday, November 21, 2007 10:40 PM
  • User742541801 posted

    That may work but not very dev-friendly or flexible.

    If you want a flexible, easy-to-use, reliable ZIP library for use within ASP.NET, try DotNetZip.

    http://www.codeplex.com/DotNetZip/Thread/View.aspx?ThreadId=46688

    DotNetZip does password-protected files, AES Encryption, ZIP64, Unicode filenames, Self-extracting archives, and more. It's fast and easy to use. Works on medium-trust sites. 

    It's free, open-source, works with VB, C# and any .NET language. Download it at http://dotnetzip.codeplex.com

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 12, 2009 2:26 AM
  • User-1320770751 posted

    have you gotten an answer to this problem ?

    Monday, May 25, 2009 5:07 AM
  • User742541801 posted

    In DotNetZip, the code to specify the folder structure in the ZIP file is like this:

     

    Response.Clear();
    Response.BufferOutput= false;
    string fileName= String.Format("files-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "inline; filename=\"" + archiveName + "\"");
    using (var z = new ZipFile())
    {
      // add a bunch of files, "flattening" them into a single dir in the zip
      z.AddFiles(listOfFiles, "files");
      // save directly to output stream for download to browser
      z.Save(Response.OutputStream);
    }
    Response.Close();
    

     

    DotNetZip is free to use.  Just download and go.  You can browse the class reference for DotNetZip here: http://cheeso.members.winisp.net/DotNetZipHelp/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 9:30 AM
  • User1016609979 posted

    You can also use chilkat built-in component for this purpose, go through the following link and you find a way.

     

    http://developersmania.blogspot.com/2010/06/creating-zip-file-using-cnet.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 1, 2010 5:09 PM
  • User-1118420479 posted

    dfcf

    Tuesday, March 8, 2011 5:17 AM
  • User-1118420479 posted

    dfcf

    Tuesday, March 8, 2011 5:17 AM
  • User-1118420479 posted

    gfvdfgdsfgdfgdf

    Tuesday, March 8, 2011 5:17 AM