Highlighted
Absent Member.
Absent Member.
1460 views

.Zip or .Rar

Jump to solution

hello,


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()

goback.

end method.

end class.

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: .Zip or .Rar

Jump to solution

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.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: .Zip or .Rar

Jump to solution

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.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.