.Zip or .Rar


I need help on creating RAR or .ZIP file

I have some sample code , but this code does not let me add more than one file , I wonder how to add more than one file

thank you

example code

*biblioteca de ZIP

$set ilusing "System.IO"

$set ilusing "System.IO.Compression"

class-id fazZip.Form1 is partial

inherits type System.Windows.Forms.Form.

working-storage section.

01 FInfo type FileInfo.

01 InStream type FileStream.

01 OutStream type FileStream.

01 ZipIt type GZipStream.

method-id NEW.

procedure division.

invoke self::InitializeComponent

*C:\teste.html FInfo::FullName

invoke new type FileInfo("c:\testebruno.txt") giving FInfo

invoke FInfo::OpenRead() giving InStream

invoke type File::Create(FInfo::FullName & ".gz") giving OutStream

invoke new type GZipStream(OutStream, type CompressionMode::Compress) giving ZipIt

invoke InStream::CopyTo(ZipIt)

invoke ZipIt::Close()

invoke InStream::Close()

invoke OutStream::Close()


end method.

end class.


  • Verified Answer

    Note this is a .NET Framework question and has nothing specifically to do with any Micro Focus product. The answer would be the same for programs written in any .NET language.

    If you create a GZipStream and write its output to a file, what you get is a gzip file, which is not a zip file. (Gailly and Adler did the world no favors when they named gzip, since it's obviously confusing.)

    The zip file format is a compound-file or archive-file format that includes a directory of contents, plus data that may be compressed with various algorithms, most often the "Deflate" algorithm.

    Gzip, on the other hand, is just Deflate-compressed data with a trivial envelope. It does not have a directory, and consequently can't (by itself) represent a collection of compressed files. The Wikipedia articles and any number of other sources provide more detail.

    The .NET Framework 4.5 offers the ZipArchive class, which you can use to create zip files. If you're using an older version of .NET, there are various free and commercial zip class libraries for .NET.

    The RAR file format can (legally) only be created by commercial software such as WinRAR. There are legal free RAR decompressors / extractors, but you can't create RAR files without using a commercial package.