Skip to main content

Past Blast

Featured Products

Stay in touch using the DEVBUSS RSS feeds.
 

News

eVB and GZip file compression

Written by John Clavey  [author's bio]  [read 27105 times]
Edited by Derek

Download the code

Page 1 

File compression within eVB or VB.NET

One of the main problems when it comes to using a Pocket PC to transfer or store data can be the size of the data. This can especially be the case if you are transferring data using a slower connection such as GSM. An ideal solution is to compress the data to reduce the size and time taken to transfer. Sapphire Solutions Ltd have developed an easy-to-use utility that can compress or decompress GZip files (.gz) and Zip files (.zip) right from your eVB or VB.NET application.

Overview

You can download the demo project of the Sapphire GZip DLL which includes a personal use version of the utility. This utility allows a selection of local files to be compressed or decompressed into the popular .zip or a single file into the .gz format. It is then possible to use any compatible compression application on a remote computer to compress or decompress these files, ideal for integrating into a back-end system.

Running the Project

After downloading and unzipping the Sapphire GZip demo project, you need to add the appropriate version of the SapphireGZip.DLL to the \Windows directory on your Pocket PC. If you are using VB.NET, you will need to include the SapphireGZip.DLL into the application directory of your program instead. You can find the correct DLL in the unzipped project directory under the appropriate sub-directory. Once you have done this you can run the desired project file on the client device.

Included with the demo project are two files, Mini.bmp and readme.txt that can be used for demonstration purposes. Simply copy those files to the \My Documents folder on your Pocket PC.

GZip files

The demo project shows how to compress or decompress both the .gz and .zip files. The GZip demo (shown above) takes a single file and compresses it giving it the .gz file extension. Moving a file to the right will compress it and moving it to the left will decompress it.

Compressing files to the zip format

To compress a series of files the demo project requires the destination zip file and a search string for all the files to zip. It is possible to include any sub directories which is ideal for backing up a particular folder on your device.

Decompressing a zip file

To decompress a zip file onto the client device, an existing zip file can be specified. It is possible to extract specific files from the zip file, or alternatively, all files. You can also specify whether you wish to use the original path names that are stored within the zip file.

The Code

To implement compression functionality in your own eVB or VB.NET application you only need to create a few simple calls to the DLL.

Example: Linking the DLL using VB.NET

<DllImport("SapphireGZip.dll")> _
Public Function sZip( _
  ByVal sFileIn As String, _
  ByVal sFileOut As String, _
  ByVal lSubDirs As Integer, _
  ByVal lLicence As Integer) As Integer
End Function

Example: Linking the DLL using eVB

Declare Function sZip _
  Lib "SapphireGZip.dll" ( _
  ByVal sFileIn As String, _
  ByVal sFileOut As String, _
  ByVal lSubDirs As Long, _
  ByVal lLicence As Long) As Long

A simple example on how to create a zip file:

lResult = sZip(sSourceFiles, sDestFile, lSubDirs, SapphireGZipLicence)

  • lResult contains the number of any possible error that may have been encountered.
  • sSourceFiles is the name or pattern of file(s) to compress.
  • sDestFile is the name of the zip file to create.
  • lSubDirs is a flag indicating whether to include sub directories. 1 = Yes, 0 = No.
  • SapphireGZipLicence is the licence number for registered users of the utility. For the demo project, this will be 1234567890.

Where to find the demo

The product information page for the latest Sapphire GZip utility allows you to download the personal use version that includes the sample eVB and VB.NET projects with the demo version of the DLL for each target platform. This can be found at www.sapphire-solutions.co.uk/product.asp?product=GZIP.

Licence of use

For those that wish to simply experiment with the utility or use it for personal projects, you can use the utility absolutely free of charge.

For those that wish to include the utility into their own commercial applications, they can purchase a royalty-free licence for the utility online at http://www.sapphire-solutions.co.uk. This is a one off payment that allows you to distribute it in any projects created under the registered company. Please refer to the web site for the latest prices.

Other utilities you may find useful

Sapphire Solutions Ltd have a variety of other utilities that you may find useful or vital to your application. Some of these are:

  • Sapphire RAS - Dial up a remote connection and manage phone book.
  • Sapphire FTP - Communicate with a FTP server (includes directory navigation).
  • Sapphire Encrypt - Encrypt or decrypt strings or files ensuring its confidentiality.
  • Sapphire IrDA - Use your application to print on an IrDA enabled printer.
  • Sapphire Buttons - Take control of other buttons on your device.

Please check www.sapphire-solutions.co.uk for a full listing of available products.