Example Code

Programmatically Create a Zip Archive with MD5 Checksum

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

Overview

This example code leverages the function to create ZIP files in LabVIEW, but also adds the capability to automatically process a directory.  

 

Description

LabVIEW has built in functionality to create ZIP files.  This example code leverages this but also adds the capability to automatically process a directory.  This way, you don't have to specify each individual file.  Instead, the code will recursively find each file in the directory you specify (including sub directories) and maintain the directory structure inside the ZIP file.

 

There is also an option to generate the MD5 checksum for the completed ZIP file.  This is useful for large files when you plan to transfer them over the network.  Once the user downloads the ZIP, they can compare your calculated MD5 to that of the copy they downloaded to make sure the checksums (and the files) are the same.  This program will store the MD5 checksum in a plain text file named <ZIP file name>_MD5.txt.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Download the attached zip file and Open Create Zip 2012 NIVerified.vi.
  2. Provide inputs for the ZIP file name and the Files/Directories to place in the archive.
  3. Run the VI.

 

Additional Information or References

 

VI Snippet of Create Zip 2012 NIVerified.vi

1.png

 

1-1.png

 

1-2.png

 

VI Snippet of Process Folder 2012 NIVerified.vi

2.png

 

 

This LabVIEW example was designed to confirm the MD5 checksum and unzip the ZIP file created by this example code.
For more information on the MD5 algorithm, please see this Wikipedia article.

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.** 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
SVinothKumar
Member
Member
on

Thanks for the example, works like a charm.

Trusted Enthusiast
Trusted Enthusiast
on

I couldn't figure what to do with the Destination Path in Zip input for the Add File to Zip VI until I saw your example.

Thanks.