SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Can not unzip the zipped file using winRAR software

Last post 12-19-2008 7:50 PM by dinesh. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 12-19-2008 7:50 PM

    • dinesh
    • Not Ranked
    • Joined on 12-19-2008
    • Posts 1

    Can not unzip the zipped file using winRAR software

    Hi,

    I have used the following code to zip files.

    // Depending on the directory this could be very large and would require more attention

    // in a commercial package.

    string[ filenames = Directory.GetFiles(args[0]);

     

    // 'using' statements gaurantee the stream is closed properly which is a big source

    // of problems otherwise. Its exception safe as well which is great.

    using (ZipOutputStream s = new ZipOutputStream(File.Create(args[1]))) {

     

    s.SetLevel(9); // 0 - store only to 9 - means best compression

     

    byte[ buffer = new byte[4096];

     

    foreach (string file in filenames) {

     

    // Using GetFileName makes the result compatible with XP

    // as the resulting path is not absolute.

    ZipEntry entry = new ZipEntry(Path.GetFileName(file));

     

    // Setup the entry data as required.

     

    // Crc and size are handled by the library for seakable streams

    // so no need to do them here.

    // Could also use the last write time or similar for the file.

    entry.DateTime = DateTime.Now;

     

    s.PutNextEntry(entry);

     

    using ( FileStream fs = File.OpenRead(file) ) {

     

    // Using a fixed size buffer here makes no noticeable difference for output

    // but keeps a lid on memory usage.

    int sourceBytes;do {

    sourceBytes = fs.Read(buffer, 0, buffer.Length);

    s.Write(buffer, 0, sourceBytes);

    }
    while ( sourceBytes > 0 );

    }

    }

     

    // Finish/Close arent needed strictly as the using statement does this automatically

     

    // Finish is important to ensure trailing information for a Zip file is appended. Without this

    // the created file would be invalid.

    s.Finish();

     

    // Close is important to wrap things up and unlock the file.

    s.Close();

    }

    But once I zipped the files using the above code, I can not unzip the file by using winRAR software. It gave an error like unknown method.

    Does anybody know how to solve this if so pls let me know...

    Thanks. 

    Filed under:
Page 1 of 1 (1 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.