Click here to Skip to main content
12,068,967 members (67,981 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
please help me...

by using third party dll the code is :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ionic.Zip;
 

namespace compression
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var zip = new Ionic.Zip.ZipFile())
            {
                zip.AddDirectory("Stuff", "rootInZipFile");
                zip.Save("Stuff.zip");
            }
        }
    }
}
Posted 27-Dec-12 19:55pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

using System;
using System.Collections.Generic;
using System.Text;
 
using System.IO;
using System.IO.Compression;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string sFileToZip = @"D:\code.txt";
            string sZipFile = @"D:\code.zip";
 
            using (FileStream __fStream = File.Open(sZipFile, FileMode.Create))
            {
                GZipStream obj = new GZipStream(__fStream, CompressionMode.Compress);
 
                byte[] bt = File.ReadAllBytes(sFileToZip);
                obj.Write(bt, 0, bt.Length);
 
                obj.Close();
                obj.Dispose();
            }
        }
    }
}
  Permalink  
Comments
dhritirao1221 28-Dec-12 2:05am
   
thanks for u hellp
dhritirao1221 28-Dec-12 2:08am
   
actually i need it has to compres upto 2gb.. i m getting error like this: The file is too long. This operation is currently limited to supporting files less than 2 gigabytes in size.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

YES, you can compress folder(s) and file(s) without any third party tool.

.NET provides classes for compression in System.IO.Compression namespace.

Try it. best of luck...
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Yes, you can compress file(s) and folder(s) using classes from System.IO.Compression namespace...
  Permalink  
Comments
dhritirao1221 28-Dec-12 1:28am
   
using System.IO.Compression;

i m using this but getting error like this


Error 1 'System.IO.FileStream' does not contain a definition for 'CopyTo' and no extension method 'CopyTo' accepting a first argument of type 'System.IO.FileStream' could be found (are you missing a using directive or an assembly reference?)

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


Advertise | Privacy | Mobile
Web01 | 2.8.160208.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100