Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

Problem with unziping files

Thread view: 
Bączek - 22 Jan 2006 17:55 GMT
Hi everyone

I've got terrible problem with unziping binary files with ICSharpCode
library. I've tried to do it by the code below with jpg files. The
files are unziped but they are unreadable. I don't know what I have to
do. Maybe it's something wrong with library. Can anybody help me??

ZipInputStream unzip =
                new ZipInputStream(File.OpenRead(@"c:\myFile.zip"));

ZipEntry entry;
while((entry = unzip.GetNextEntry()) != null)
{

    FileStream s =
        new FileStream(@"c:\test.jpg",FileMode.Create);

    while(true)
    {
        size = unzip.Read(buffer,0,buffer.Length);
        if(size > 0)
            s.Write(buffer,0,buffer.Length);
        else
               break;
    }
    s.Close();
}
unzip.Close();
Baczek - 22 Jan 2006 20:26 GMT
Sorry it's me once again I made mistake when I wanted to show you my
code I deleted some not important information but I also deleted some
code that must be implemented. So I write code once again

ZipInputStream unzip = new
ZipInputStream(File.OpenRead(@"c:\myZip.zip"));

ZipEntry entry;
while((entry = unzip.GetNextEntry()) != null)
{
 int size = 256;
 byte[] buffer = new byte[256];
 FileStream s = new FileStream(@"c:\test.jpg",FileMode.Create);
 while(true)
 {
    size = unzip.Read(buffer,0,buffer.Length);
    if(size > 0)
        s.Write(buffer,0,buffer.Length);
    else
        break;
 }
 s.Close();
}
unzip.Close();

Sorry for this


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.