Highlighted
Absent Member.
Absent Member.
1085 views

Zip a file in Visual Cobol

Jump to solution

Hi,

I want to ZIP one file contained in a PC's local directory.

Can anyone advise how to convert this into cobol?

//Creates a new, blank zip file to work with - the file will be
//finalized when the using statement completes
using (ZipArchive newFile = ZipFile.Open(zipName, ZipArchiveMode.Create))
{
    //Here are two hard-coded files that we will be adding to the zip
    //file.  If you don't have these files in your system, this will
    //fail.  Either create them or change the file names.
    newFile.CreateEntryFromFile(@"C:\Temp\File1.txt", "File1.txt");
    newFile.CreateEntryFromFile(@"C:\Temp\File2.txt", "File2.txt", CompressionLevel.Fastest);
}

Taken from the website:-

http://www.codeproject.com/Articles/381661/Creating-Zip-Files-Easily-in-NET
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Zip a file in Visual Cobol

Jump to solution

Hi Neil, should be something like:

declare zipName = "File.dat"

perform using newFile as type ZipArchive = type ZipFile::Open(zipName, type ZipArchiveMode::Create)

   *>Here are two hard-coded files that we will be adding to the zip

   *>file.  If you don't have these files in your system, this will

   *>fail.  Either create them or change the file names.

   invoke newFile::CreateEntryFromFile("C:\Temp\File1.txt", "File1.txt");

   invoke newFile::CreateEntryFromFile("C:\Temp\File2.txt", "File2.txt", type CompressionLevel::Fastest);

end-perform

View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Zip a file in Visual Cobol

Jump to solution

Hi Neil, should be something like:

declare zipName = "File.dat"

perform using newFile as type ZipArchive = type ZipFile::Open(zipName, type ZipArchiveMode::Create)

   *>Here are two hard-coded files that we will be adding to the zip

   *>file.  If you don't have these files in your system, this will

   *>fail.  Either create them or change the file names.

   invoke newFile::CreateEntryFromFile("C:\Temp\File1.txt", "File1.txt");

   invoke newFile::CreateEntryFromFile("C:\Temp\File2.txt", "File2.txt", type CompressionLevel::Fastest);

end-perform

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Zip a file in Visual Cobol

Jump to solution

thanks for that works great.

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.