Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
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 = @"C:\MyDocuments\123.txt";
            string sZipFile = @"C:\MyDocuments\";
            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);
Posted 27-Dec-12 20:14pm
Sergey Alexandrovich Kryukov at 28-Dec-12 2:16am
How about third-party source code, even better quality than 1st party, would not mind? :-) —SA
dhritirao1221 at 28-Dec-12 2:20am
actually ididnt get u, but what i mean to say is i have already worked the same with using third party dll i.e using ionic but now my t.l want to work me with out using any third party dll. but as per the above i m able to Zip for very less size files. i need it for upto 2gb
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Use DotNetZip ([^])
it will solve your problem. Smile | :)
If you don't want to download any thing then try this : Compress Zip files with Windows Shell API and C#[^]
dhritirao1221 at 28-Dec-12 2:22am
i dnot want to downlaod any libraries
Suvabrata Roy at 28-Dec-12 2:27am
Its Free, you can freely used it in your project.
dhritirao1221 at 28-Dec-12 4:15am
ya i to know its free of cost. but without using those is there any possibility i asked.
Suvabrata Roy at 28-Dec-12 4:46am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The thing is: GZip is not zip. This is a different compression format.
To work with ZIP, you can use #ziplib:[^].
Another option is using SevenZipSharp, a .NET wrapper of the famous 7-Zip:[^],[^].
Both ZIP libraries are open-source. So, you won't have to use any "3rd-party DLLs".
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

dhritirao1221 at 28-Dec-12 4:14am
ok thanks for ur help
ProgramFOX at 28-Dec-12 7:46am
You're welcome!

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

  Print Answers RSS
Your Filters
0 Shai Vashdi 456
1 OriginalGriff 183
2 Sergey Alexandrovich Kryukov 171
3 Tadit Dash 160
4 praveen_07 115
0 Sergey Alexandrovich Kryukov 9,280
1 OriginalGriff 5,473
2 Peter Leow 4,100
3 Maciej Los 3,540
4 Abhinav S 3,333

Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid