Thomas Sasnett (ThomasSasnett)
Lead Robotics Architect u2013 Pega Consulting
Pegasystems Inc.
ThomasSasnett Member since 2016 10 posts
Posted: January 6, 2017
Last activity: January 23, 2018
Posted: 6 Jan 2017 8:29 EST
Last activity: 23 Jan 2018 6:26 EST

Zipping and Unzipping Files in Pega Robotics

If you ever have the need to zip and/or Unzip files within a Pega Robotics solution, here are a few scripts that can be used to do just that using a dll shipped with Pega Robotics Studio.

  1. Add a new script component to your global container.
  2. Right-click the component and add a reference to the ICSharpCode.SharpZipLib.dll located in the installation directory for Pega Robotics Studio (or the plugin).

3. Finally, create all four scripts using the attached text files.

4. The _CompressFolder script should be added first as it is used by one of the others.

When zipping a file, drap the ZipFile method from the script into your automation. It accepts three parameters;

  • zipFileName - This is what you want to name your resulting zip file.
  • password - This can be left blank, or you may supply a password.
  • folderToZip - The path to the folder containing the file(s) you want to zip. This will not zip an individual file as written, however you could possibly modify the script to do so if required.

When unzipping a file, drag the UnzipFile or UnzipFilePassword method out to your automation. These methods are identical except that the latter would be used if the zip file were password protected. The parameters for UnzipFilePassword are;

  • archiveFileNameIn - The full path to the zip file
  • password - The password for the archive
  • outFolder - The directory to unzip the file to

The parameters for UnzipFile are;

  • zipFileName - The full path to the zip file
  • targetDir - The directory to unzip the file to
Robotic Process Automation Developer Knowledge Share