Home All Groups Group Topic Archive Search About
Author
10 Mar 2006 9:17 PM
Necqui Teja
Are there any utils/tools to zip files at runtime in C#?

Thanks

Necqui

Author
10 Mar 2006 9:29 PM
Jon Skeet [C# MVP]
Necqui Teja <NecquiT@nospam.nospam> wrote:
> Are there any utils/tools to zip files at runtime in C#?

See http://www.icsharpcode.net/OpenSource/SharpZipLib/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
Are all your drivers up to date? click for free checkup

Author
10 Mar 2006 10:03 PM
Fabio
"Necqui Teja" <NecquiT@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
Author
10 Mar 2006 10:15 PM
Jon Skeet [C# MVP]
Fabio <znt.fa***@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
Author
11 Mar 2006 5:00 AM
Jordan
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



Show quoteHide quote
"Necqui Teja" <NecquiT@nospam.nospam> wrote in message
news:uSE9AgIRGHA.1416@TK2MSFTNGP12.phx.gbl...
> Are there any utils/tools to zip files at runtime in C#?
>
> Thanks
>
> Necqui
>
Author
11 Mar 2006 7:30 AM
Jon Skeet [C# MVP]
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
Author
11 Mar 2006 8:35 PM
Jordan
RE:
<<  ...a lot more complicated...  >>

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





Show quoteHide quote
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MPG.1e7c8cfff00611c798cf23@msnews.microsoft.com...
> 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
Author
12 Mar 2006 12:01 AM
Nick Malik [Microsoft]
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.
--
Show quoteHide quote
"Jordan" <A@B.COM> wrote in message
news:ufXzPtURGHA.4976@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:MPG.1e7c8cfff00611c798cf23@msnews.microsoft.com...
>> 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
>
>
Author
12 Mar 2006 2:11 AM
Jordan
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



Show quoteHide quote
"Nick Malik [Microsoft]" <nickmalik@hotmail.nospam.com> wrote in message
news:65GdnUzJlvGb-Y7ZRVn-tg@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:ufXzPtURGHA.4976@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:MPG.1e7c8cfff00611c798cf23@msnews.microsoft.com...
>>> 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
>>
>>
>
>
Author
12 Mar 2006 7:19 AM
Jon Skeet [C# MVP]
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
Author
15 Mar 2006 4:06 PM
AlexL [Xceed]
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: xLebla***@xceedsoft.com (remove the first 'x')
Author
13 Mar 2006 3:33 AM
TerryFei
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.)


--------------------
Show quoteHide quote
>From: "Necqui Teja" <NecquiT@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: <uSE9AgIRGHA.1***@TK2MSFTNGP12.phx.gbl>
>Newsgroups: microsoft.public.dotnet.languages.csharp
>NNTP-Posting-Host: 216.57.203.121
>Path: TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.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
>
>
>
Author
13 Mar 2006 8:07 AM
Jon Skeet [C# MVP]
"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
Author
13 Mar 2006 9:12 AM
TerryFei
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/compresswithwinshellapics.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: <1142237264.117314.144***@z34g2000cwc.googlegroups.com>
>References: <uSE9AgIRGHA.1***@TK2MSFTNGP12.phx.gbl>
>   <kqP7w7kRGHA.6***@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: groups-ab***@google.com
>NNTP-Posting-Date: Mon, 13 Mar 2006 08:07:51 +0000 (UTC)
>In-Reply-To: <kqP7w7kRGHA.6***@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: groups-ab***@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!newsfeed00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.gigan
ews.com!postnews.google.com!z34g2000cwc.googlegroups.com!not-for-mail
Show quoteHide quote
>Xref: 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
>
>

Bookmark and Share