473,473 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Zip Files In C#

Hi,

I need to write some functionality in C# that will zip files. I've
been doing some reading of previous posts and saw some good info but
I'm bound by the following restrictions:

1) I may not be able to use a third party tool - we have some
restrictions on this.
2) I can't use J#.
3) I don't have Visual Studio .NET 2005 (we're currently still using
1.1).

Is there some way I can write code myself in C# with 1.1 and be able to
zip files? Or do my restrictions pretty much prevent me from doing
this?

Aug 1 '06 #1
11 3719
If this was me, I'd want to have #1 *very* well defined:
I may not be able to use a third party tool - we have some
restrictions on this.
It isn't clear what this means... bought-in? CLR only?

The CLR offers a few /stream/ compression classes, but not zip, which
is a more complex structure of multiple compressed streams along with
file headers. SharbZipLib would be the obvious choice here; the license
is fairly open. Else perhaps Process.Start to existing command-line
tools (e.g. the aging pkzip, what else?)...

Otherwise, you are going to be writing (and testing) a lot of very risk
stuff. And why?

Sorry I don't have a better answer,

Marc

Aug 1 '06 #2
zsharplib is open source implementation that you could atleast copy if it is
still considerred "3rd party"

http://www.icsharpcode.net/OpenSource/SharpZipLib/

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Doug" <dn******@dtgnet.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi,

I need to write some functionality in C# that will zip files. I've
been doing some reading of previous posts and saw some good info but
I'm bound by the following restrictions:

1) I may not be able to use a third party tool - we have some
restrictions on this.
2) I can't use J#.
3) I don't have Visual Studio .NET 2005 (we're currently still using
1.1).

Is there some way I can write code myself in C# with 1.1 and be able to
zip files? Or do my restrictions pretty much prevent me from doing
this?

Aug 1 '06 #3
Darn - proved myself wrong already:

http://www.codeproject.com/csharp/de...select=1253354

This seems to use PInvoke and the Win32 API; personally I'd find
SharpZipLib more friendly.

Marc

Aug 1 '06 #4
Hello Doug,

There are a number of 3rd party tools (some even free...like beer), but I
can't suggest any until I understand your restrictions on 3rd party tools.
I am not sure it can be done without a 3rd party component. You can do
compression but probably not in the .zip format.
Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
Hi,

I need to write some functionality in C# that will zip files. I've
been doing some reading of previous posts and saw some good info but
I'm bound by the following restrictions:

1) I may not be able to use a third party tool - we have some
restrictions on this.
2) I can't use J#.
3) I don't have Visual Studio .NET 2005 (we're currently still using
1.1).
Is there some way I can write code myself in C# with 1.1 and be able
to zip files? Or do my restrictions pretty much prevent me from doing
this?

Aug 1 '06 #5
Shawn/Marc - We can use third party tools but we're pretty limited, it
requires a pretty heavy research process to get approval for them (it
took me nearly a year to get NUnit approved!!) So I'm a little
hesitant to use third party tools unless I have no other option.

Greg, you had mentioned copying the code from zSharpLib. Is that okay
to do? I am not familiar with all the rules involved with open source
code.

Marc - I had read the codeproject.com article you referenced, but I
couldn't determine what reference to add to get the "Shell32" code to
work?

Aug 1 '06 #6
Shawn Wildermuth <sw*********@newsgroup.nospamwrote:
There are a number of 3rd party tools (some even free...like beer), but I
can't suggest any until I understand your restrictions on 3rd party tools.
I am not sure it can be done without a 3rd party component. You can do
compression but probably not in the .zip format.
Well, there's nothing to stop the OP from performing the same level of
implementation that the SharpZipLib team did. It will, however, take a
very long time and is unlikely to end up as well tested as SharpZipLib
(just through being used by fewer people).

--
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
Aug 1 '06 #7
To quote from the article:

"To make this code work, you will also need to set a reference to a COM
library. In the References window, go to the COM tab and select the
library labeled 'Microsoft Shell Controls And Automation'."

Marc

Aug 1 '06 #8
Shawn Wildermuth (C# MVP) <sw*********@newsgroup.nospamwrote:
Hello Doug,

There are a number of 3rd party tools (some even free...like beer), but I
can't suggest any until I understand your restrictions on 3rd party tools.
I am not sure it can be done without a 3rd party component. You can do
compression but probably not in the .zip format.
Of course it can be done without a 3rd party component - one can always
roll one's own - it's just a question of economic efficiency!

Zip files use 'gzip' (available through GZipStream) compression
internally, but they also have header and directory information that
need to be maintained. It's the management of the headers and
directories that .NET doesn't have natively.

-- Barry

--
http://barrkel.blogspot.com/
Aug 1 '06 #9
I think it would be better to question the policy of making you rewrite open
source code as there is no good reason why you wouldn't use it as is ... A
3rd party control argument can be made in regards to buying controls or in
using controls that are not open source as you may end up at the mercy of
whoever is maintaining it but with open source ... you have source.

Cheers,

Greg
"Doug" <dn******@dtgnet.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Shawn/Marc - We can use third party tools but we're pretty limited, it
requires a pretty heavy research process to get approval for them (it
took me nearly a year to get NUnit approved!!) So I'm a little
hesitant to use third party tools unless I have no other option.

Greg, you had mentioned copying the code from zSharpLib. Is that okay
to do? I am not familiar with all the rules involved with open source
code.

Marc - I had read the codeproject.com article you referenced, but I
couldn't determine what reference to add to get the "Shell32" code to
work?

Aug 1 '06 #10
Why not just install C1Zip into the Gac and use it.

ComponentOne Zip for .NET
Zip for .NET Setup Files

It is a free download from

http://helpcentral.componentone.com/...gzipfornet.htm

Aug 2 '06 #11

"Dennis Passmore" <de*****@dpassmore.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Why not just install C1Zip into the Gac and use it.

ComponentOne Zip for .NET
Zip for .NET Setup Files

It is a free download from

http://helpcentral.componentone.com/...gzipfornet.htm
Free the download, not the product. The trial version puts up banners when
used without a license.
--
WildHeart'2k5
Aug 4 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
3
by: pooja | last post by:
Suppose i have created a class c1 with f1()in c1.cpp and included this c1.cpp in file1.cpp file , which is also having main() by giving the statement #include "c1.cpp". the same i can do by...
11
by: ambika | last post by:
Iam just trying to know "c". And I have a small doubt about these header files. The header files just contain the declaration part...Where is the definition for these declarations written??And how...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
0
by: wal | last post by:
How does one attach files to emails using libgmail? The following code http://pramode.net/articles/lfy/fuse/4.txt works fine when said files are simple text files, but it failes as soon as the...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.