By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,857 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,857 IT Pros & Developers. It's quick & easy.

ZIP files in C#

P: n/a
Are there any utils/tools to zip files at runtime in C#?

Thanks

Necqui
Mar 10 '06 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Necqui Teja <Ne*****@nospam.nospam> wrote:
Are there any utils/tools to zip files at runtime in C#?


See http://www.icsharpcode.net/OpenSourc...b/Default.aspx

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 10 '06 #2

P: n/a
"Necqui Teja" <Ne*****@nospam.nospam> ha scritto nel messaggio

Are there any utils/tools to zip files at runtime in C#?


If you are using vs2005 you can also use the
System.IO.Compression.GZipStream class.
--

Free .Net Reporting Tool - http://www.neodatatype.net
Mar 10 '06 #3

P: n/a
Fabio <zn*******@virgilio.it> wrote:
Are there any utils/tools to zip files at runtime in C#?


If you are using vs2005 you can also use the
System.IO.Compression.GZipStream class.


While that gives compression and will cope with gzip files, I don't
believe it'll help much with "normal" zip files.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 10 '06 #4

P: n/a
Highly recommended: http://www.7-zip.org/
Here's their Sourceforge page: http://sourceforge.net/projects/sevenzip/

Two versions are available - one with a GUI and a compact (< 500K ) command
line version that you can execute from your code - passing in parameters for
what to zip (input and output file name).

And it's free.

-HTH

"Necqui Teja" <Ne*****@nospam.nospam> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
Are there any utils/tools to zip files at runtime in C#?

Thanks

Necqui

Mar 11 '06 #5

P: n/a
Jordan <A@B.COM> wrote:
Highly recommended: http://www.7-zip.org/
Here's their Sourceforge page: http://sourceforge.net/projects/sevenzip/

Two versions are available - one with a GUI and a compact (< 500K ) command
line version that you can execute from your code - passing in parameters for
what to zip (input and output file name).

And it's free.


Starting a separate process makes life a lot more complicated than
using a library from within your own code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 11 '06 #6

P: n/a
RE:
<< ...a lot more complicated... >>

Can you explain? It seems pretty straight-forward to me.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Jordan <A@B.COM> wrote:
Highly recommended: http://www.7-zip.org/
Here's their Sourceforge page: http://sourceforge.net/projects/sevenzip/

Two versions are available - one with a GUI and a compact (< 500K )
command
line version that you can execute from your code - passing in parameters
for
what to zip (input and output file name).

And it's free.


Starting a separate process makes life a lot more complicated than
using a library from within your own code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 11 '06 #7

P: n/a
Jon is right, Jordan. Calling a seperate app from your code creates a slew
of dependencies and issues for applications. I'd recommend against it.

Examples:
-- Customer A works for a large corporation that controls the manner in
which apps can be installed on the desktop. They review the install for
your app and, seeing that you are installing two executables instead of one,
simply refuse to allow the app to be installed. (= lost sale).

-- Customer B installs your app and then, the next day, downloads a zip file
sent from their customer. They double-click the zip file, as always, but
this time, a different app opens up to handle it because your zip app has
registered itself to handle files with the extension of .ZIP. They freak
out and call Customer Support in their company. After hours of frustration,
customer support figures out that the customer had installed your app, and
advises them to uninstall your app. They then place a rule in the corporate
knowledge base to advise everyone else to uninstall the app as well. (=
lost sale and lost reputation)

-- Customer C has a memory constrained environment. They run your app,
which attempts to decompress a large file. This takes a long time. Because
the zip app is external and async, your app thinks that the uncompression
has completed already and attempts to open the uncompressed file, which
fails. (= impression of code defects)

-- Customer D hears of a virus that has shown up and proactively searches on
their machine for files of a specific name. They find the zip program and
delete it. Your app simply starts to fail. (= impression of poor quality).

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Jordan" <A@B.COM> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
RE:
<< ...a lot more complicated... >>

Can you explain? It seems pretty straight-forward to me.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Jordan <A@B.COM> wrote:
Highly recommended: http://www.7-zip.org/
Here's their Sourceforge page: http://sourceforge.net/projects/sevenzip/

Two versions are available - one with a GUI and a compact (< 500K )
command
line version that you can execute from your code - passing in parameters
for
what to zip (input and output file name).

And it's free.


Starting a separate process makes life a lot more complicated than
using a library from within your own code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Mar 12 '06 #8

P: n/a
Thanks Nick.

Your explanations and examples are all helpful. They all have to do with the
non technical aspects of calling another application. Granted, those "non
technical aspects" are critically important and reason enough, I'd agree, to
avoid calling another application in those and similar scenarios.

Mr. Skeet's advice, however, seemed to imply some *technical issues* with
calling another application (he wrote, "Starting a separate process...
[causes problems]"). If that was his meaning then I'd still be interested in
knowing any technical issues because I'm currently doing what he is advising
against. I have a simple Console app that gets executed by the Windows Task
Scheduler on a nightly basis. It looks for files in a folder and zips any
that are found as part of a data archiving routine. If there is some
technical issue with doing this I'd be very interested in knowing what they
are.

Thanks again!

-J

"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:65********************@comcast.com...
Jon is right, Jordan. Calling a seperate app from your code creates a
slew of dependencies and issues for applications. I'd recommend against
it.

Examples:
-- Customer A works for a large corporation that controls the manner in
which apps can be installed on the desktop. They review the install for
your app and, seeing that you are installing two executables instead of
one, simply refuse to allow the app to be installed. (= lost sale).

-- Customer B installs your app and then, the next day, downloads a zip
file sent from their customer. They double-click the zip file, as always,
but this time, a different app opens up to handle it because your zip app
has registered itself to handle files with the extension of .ZIP. They
freak out and call Customer Support in their company. After hours of
frustration, customer support figures out that the customer had installed
your app, and advises them to uninstall your app. They then place a rule
in the corporate knowledge base to advise everyone else to uninstall the
app as well. (= lost sale and lost reputation)

-- Customer C has a memory constrained environment. They run your app,
which attempts to decompress a large file. This takes a long time.
Because the zip app is external and async, your app thinks that the
uncompression has completed already and attempts to open the uncompressed
file, which fails. (= impression of code defects)

-- Customer D hears of a virus that has shown up and proactively searches
on their machine for files of a specific name. They find the zip program
and delete it. Your app simply starts to fail. (= impression of poor
quality).

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Jordan" <A@B.COM> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
RE:
<< ...a lot more complicated... >>

Can you explain? It seems pretty straight-forward to me.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Jordan <A@B.COM> wrote:
Highly recommended: http://www.7-zip.org/
Here's their Sourceforge page:
http://sourceforge.net/projects/sevenzip/

Two versions are available - one with a GUI and a compact (< 500K )
command
line version that you can execute from your code - passing in
parameters for
what to zip (input and output file name).

And it's free.

Starting a separate process makes life a lot more complicated than
using a library from within your own code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too



Mar 12 '06 #9

P: n/a
Jordan <A@B.COM> wrote:
RE:
<< ...a lot more complicated... >>

Can you explain? It seems pretty straight-forward to me.


Starting separate processes is more complicated in terms of:

1) Redirecting standard output/error, depending on what the process
does
2) Capturing precise error information - an exception can be a lot more
useful than an error number
3) The options available - how would you open a zip file and read one
entry *in memory* using a separate process?
4) Security - who is the process going to run as? Will that user always
have enough permissions to do everything you'd be able to do within
the CLR if, say, impersonation is involved?
5) Security the other way round - perhaps the process will end up with
*more* permissions than the .NET sandboxed process.
Libraries are just a lot easier to work with than separate processes,
unless all you want to do is exactly what the other program would do.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 12 '06 #10

P: n/a
Hi Necqui,
Welcome to MSDN Newsgroup!

I hope the following article will be helpful for you:
Title: ZIP Code Utility
URL: http://www.codeproject.com/csharp/zipcodeutil.asp

Thanks and have a nice day!

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
From: "Necqui Teja" <Ne*****@nospam.nospam>
Subject: ZIP files in C#
Date: Fri, 10 Mar 2006 13:17:12 -0800
Lines: 7
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
Message-ID: <uS**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 216.57.203.121
Path: TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.dotnet.languages.csharp:391401
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Are there any utils/tools to zip files at runtime in C#?

Thanks

Necqui


Mar 13 '06 #11

P: n/a
"TerryFei" wrote:
I hope the following article will be helpful for you:
Title: ZIP Code Utility
URL: http://www.codeproject.com/csharp/zipcodeutil.asp

Thanks and have a nice day!


Wrong kind of zip. From the first line of the article:

<quote>
This article provides an easy method to lookup a U.S. City/State by ZIP
Code, or one or more ZIP Codes by City/State.
</quote>

In other words, nothing to do with zip *files*.

Jon

Mar 13 '06 #12

P: n/a
Hi ,

Sorry, I have misunderstood the meaning. Based on my knowledge, if we want
to compress file , we can use ZLIB library to achieve it.
I also hope the following article will be helpful:
Title: Compress Zip files with Windows Shell API and C#
URL:http://www.codeproject.com/csharp/co...shellapics.asp
Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
From: "Jon Skeet [C# MVP]" <sk***@pobox.com>
Newsgroups: microsoft.public.dotnet.languages.csharp
Subject: Re: ZIP files in C#
Date: 13 Mar 2006 00:07:44 -0800
Organization: http://groups.google.com
Lines: 18
Message-ID: <11**********************@z34g2000cwc.googlegroups .com>
References: <uS**************@TK2MSFTNGP12.phx.gbl>
<kq**************@TK2MSFTNGXA03.phx.gbl>
NNTP-Posting-Host: 213.146.158.130
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1142237271 11332 127.0.0.1 (13 Mar 2006 08:07:51 GMT)X-Complaints-To: gr**********@google.com
NNTP-Posting-Date: Mon, 13 Mar 2006 08:07:51 +0000 (UTC)
In-Reply-To: <kq**************@TK2MSFTNGXA03.phx.gbl>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051111 Firefox/1.5,gzip(gfe),gzip(gfe)X-HTTP-Via: 1.1 Clearswift Web Policy Engine
Complaints-To: gr**********@google.com
Injection-Info: z34g2000cwc.googlegroups.com; posting-host=213.146.158.130;
posting-account=wlYlwRMAAABhmH17w-KED1nF-HZQHW_udygjClLVOm2VliHq0ftfvw
Path: TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.d ca.giganews.com!nntp.gigan
ews.com!postnews.google.com!z34g2000cwc.googlegrou ps.com!not-for-mailXref: TK2MSFTNGXA03.phx.gbl microsoft.public.dotnet.languages.csharp:391703
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

"TerryFei" wrote:
I hope the following article will be helpful for you:
Title: ZIP Code Utility
URL: http://www.codeproject.com/csharp/zipcodeutil.asp

Thanks and have a nice day!


Wrong kind of zip. From the first line of the article:

<quote>
This article provides an easy method to lookup a U.S. City/State by ZIP
Code, or one or more ZIP Codes by City/State.
</quote>

In other words, nothing to do with zip *files*.

Jon


Mar 13 '06 #13

P: n/a
On Sat, 11 Mar 2006 07:30:41 -0000, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
Jordan <A@B.COM> wrote:
Highly recommended: http://www.7-zip.org/
Here's their Sourceforge page: http://sourceforge.net/projects/sevenzip/

Two versions are available - one with a GUI and a compact (< 500K ) command
line version that you can execute from your code - passing in parameters for
what to zip (input and output file name).

And it's free.


Starting a separate process makes life a lot more complicated than
using a library from within your own code.


Also, you might want to have an entirely managed solution, as well, so
when looking for a .NET Zip compression component, be sure you don't
fall into the trap of thinking you purchased a .NET Zip component but
it is actually just a .NET wrapper over unmanaged code. Only the most
reputable companies offer this (Xceed, Dart, /n Software) and also
sharpZipLib, if you have more time on your hands or don't need
advanced capabilities (like support for more than 4GB, immediate help
by email, great documentation, etc.)

--
Alex Leblanc
Xceed Software Inc.
http://www.xceedsoft.com

Check out our advanced .NET grid and Windows Forms UI controls

Email: xL*******@xceedsoft.com (remove the first 'x')
Mar 15 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.