473,605 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issues with SharpZipLib

Hi all,

I've been trying to use the SharpZipLib as it sounds promising and a
lot of people refer to it in discussions on compression. However, I am
getting some bad output, when I try to unzip a (correctly hand made)
..zip file via code. I DO get the right amount of files, however, some
seem cut in half ... when viewing the output files directly, some of
the .gif file show only half, some of the included .swf files show
nothing.

Furthermore, the filenames get corrupted when using special
characters.

Could someone with experience in using the SharpZipLib, please give me
a view on my troubles? Extraction code below...

Kind regards,
Christer

string rootPath = @"c:\sletmig \";
FlushExtractDir (); //Delete existing output directory
ZipFile zFile = new ZipFile(rootPat h + "vejledning.zip ");
try
{
//For each entry in zip file...
foreach (ZipEntry e in zFile)
{

string fileName = Path.GetFileNam e(rootPath + @"udpak\" + e.Name);
string directoryName = Path.GetDirecto ryName(rootPath + @"udpak\" +
e.Name);

//Ensure directory...
if (!Directory.Exi sts(directoryNa me))
{
Directory.Creat eDirectory(dire ctoryName);
}
//If file entry, create the file...
if (fileName.Lengt h > 0)
{
System.IO.Strea m s = zFile.GetInputS tream(e);

int length = (int)e.Size;
byte[] bytes = new byte[length];
s.Read(bytes, 0, length);
FileStream newfile = new FileStream(root Path + @"udpak\" + e.Name,
FileMode.Create );
newfile.Write(b ytes, 0, length);
newfile.Close() ;
s = null;
}
}
}
finally
{
zFile.Close();
}
Jul 21 '05 #1
2 2849
I'm not sure, but I ran into a similar issue to this and I think you
need to check the return value from the s.Read call. It's possible
that it is not reading all the bytes from the zip stream. I think you
need to run it in a loop and keep reading until there is no more data
to read. I don't have the code I used at hand, but when I can find it
I'll post it.

Chris

Jul 21 '05 #2
Christer <wi******@hotma il.com> wrote:
I've been trying to use the SharpZipLib as it sounds promising and a
lot of people refer to it in discussions on compression. However, I am
getting some bad output, when I try to unzip a (correctly hand made)
.zip file via code. I DO get the right amount of files, however, some
seem cut in half ... when viewing the output files directly, some of
the .gif file show only half, some of the included .swf files show
nothing.
See http://www.pobox.com/~skeet/csharp/readbinary.html

Don't assume that Stream.Read will return as many bytes as you
requested from it in one go.
Furthermore, the filenames get corrupted when using special
characters.


That I'm not sure about - there may be a restriction in the zip format
itself.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3

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

Similar topics

1
9285
by: BeanDog | last post by:
I know this is a horse that's been beated good and dead, but I *still* can't find a good solution to this. I suppose I should post this on SharpZipLib's forums, but I signed up and they never sent me a confirmation email, and I can't resign up with the same email address. Great. I'm trying to unzip from a byte array to a byte array using SharpZipLib. Consider the following C# code: MemoryStream msIn = new MemoryStream(bFile, 0,...
1
4914
by: Calvin Slater | last post by:
I am always getting the following error when debuging ASP.NET application: Access is denied: 'ICSharpCode.SharpZipLib'. At this point I have to reboot IIS to get the web site going again. It appears that if you are debuging your application it leaves SharpZipLib in some strange state. If you wait long enough it will eventually clean itself up.
1
9680
by: Flix | last post by:
The following piece of code should turn the folder IN and its subfolders into a single tar file located in the folder OUT: using ICSharpCode.SharpZipLib; using ICSharpCode.SharpZipLib.Tar; public static void Create_Tar_Archive(string IN,string OUT) { //IN and OUT are directories
1
1659
by: Yogi_Bear_79 | last post by:
I recently some embedded GZIP files into my project. I added the sharpziplib.dllas a referance. But when I distribute the .exe it looks for the .dll. Did I do something wrong, or miss step? I don't want to have to distribute the .dll, I was hoping to continue this as a stand alone .exe
3
3569
by: phonious | last post by:
Could someone help me out with some good sample code in C# using SharpZipLib. I am a VB guy trying to support a C# app. Any help would be greatly appreciated.
1
3505
by: Brian Henry | last post by:
I keep getting this error when decompressing any zip files.. ICSharpCode.SharpZipLib.ZipException: Wrong Local header signature: 0xB023867F at ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry() at BeneFTPHostService.BeneFTPHostService.ProcessQueue() in C:\reschinidev\benefits application\BeneFTPHostService\BeneFTPHostService.vb:line 187
4
7800
by: Sam | last post by:
Hi all, Does someone knows if I can use this librairy (ICSharpCode.SharpZipLib.Zip) for free ? It is used to zip files (as you can probably guess). Thank you very much. Samuel
2
560
by: Christer | last post by:
Hi all, I've been trying to use the SharpZipLib as it sounds promising and a lot of people refer to it in discussions on compression. However, I am getting some bad output, when I try to unzip a (correctly hand made) ..zip file via code. I DO get the right amount of files, however, some seem cut in half ... when viewing the output files directly, some of the .gif file show only half, some of the included .swf files show nothing.
3
36998
by: CodeTalker | last post by:
I am new to VB.NET and SharpZipLib for that matter. I need the ability to zip a single file. I have found many examples of unzipping a zip file but not one to actually zip one. If anyone has an example of this I would GREATLY appreciate it.
0
7931
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8423
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8411
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8067
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5885
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3956
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2437
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 we have to send another system
1
1530
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1270
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.