Corfu Navision 2016, Development Tips, How To, Tip & Tricks

Zip/Un-Zip files using 7Zip

Dear friends today I am sharing functionality created in Navision which can be used to zip or Un-Zip files. Upon request of one of follower of my blog I decided to discuss on this point.

Here below I present below how we can do the same. The variables, functions and process is self-explanatory.

Step 1: Let us create a Setup Table and Page

Zip-UnZip-1

Zip-UnZip-2

Zip-UnZip-3

Step 2: Let us define variables

Zip-UnZip-4

Name                                                    DataType             Subtype                    Length

netProcess                                         DotNet                 System.Diagnostics.Process.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

netProcessStartInfo                       DotNet System.Diagnostics.ProcessStartInfo.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

netProcessWindowStyle              DotNet System.Diagnostics.ProcessWindowStyle.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

ImportPath                                         Text                                                        1024

ExportPath                                         Text                                                         1024

ZipPath                                                 Text                                                        1024

ImportExportSetup                         Record                  Import Export Setup

Order                                                    Text                                                          1024 

Step 3: Let us create a Function to Get Information of Path from Setup:

Zip-UnZip-5

This function is to initialize all the required variables which will be used in other functions.

It takes value from the Setup created above to store path of required folders. 

Step 4: Let us create a Function for running Shell Command for 7zip Files:

Zip-UnZip-6

This function runs the shell script in background to Zip or Un-Zip files in specified folder.

Step 5: Let us create a Function to call UnZip file after preparing the Parameters for Command

Zip-UnZip-7

This function prepares the path, Name of File and Argument for the Shell and finally calls the Shell function to run the command in background. At the end of function you will get UnZiped files from the Zip file.

Step 6: Let us create a Function to call Zip file after preparing the Parameters for Command

Zip-UnZip-8

Zip-UnZip-9

This function prepares the path, Name of File and Argument for the Shell and finally calls the Shell function to run the command in background. At the end of function you will get Ziped file which contains the file specified in InclusiveFiles.

This way you can use above functions to Zip / Un-Zip files using 7Zip.