Post your tools and samples or ask for them.
Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Posts: 2956
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands


Post by Dave Rabelink » 05 Jan 2021, 12:43


The TD functions SalStrCompress and SalStrUncompress use a TD specific compression algorithm.

To be able to compress and uncompress in .NET and use the algorithm in C# projects this library is created.
It does not need a TD runtime installation or any other 3rd party dependencies.

The solution contains 3 projects.


This is a standalone assembly (dll) which contains several methods to compress and uncompress.
It can be used as reference in any .NET projects and does not need any other external references.

These methods are available:
(see source for details)
  • SalCompress -> compress byte array
  • SalCompressFromFile -> compress file to byte array
  • SalCompressToFile -> compress byte array to file
  • SalUncompress -> uncompress byte array
  • SalUncompressFromFile -> uncompress file to byte array
  • SalUncompressToFile -> uncompress byte array to file
  • SalIsCompressed -> Check if byte array is compressed
  • SalGetCompressionInfo -> Get compression header info from byte array
  • SalFileGetCompressionInfo -> Get compression header info from file
  • SalFileCompress -> Compress input file to output file
  • SalFileUncompress -> Uncompress input file to output file

Instead of referencing the assembly you can include the main source into your project to use the methods directly without the assembly.


This is a simple tool (executable) which uses the non-referenced way of using the compression API.
It can be used as a console application or as a GUI application. The executable can be used standalone, the SALCompression.dll is not needed.

When started from command (cmd) you can compress/uncompress files and get compression info.


Code: Select all

SALCompressionCmd [/C] [/U] [/I] source destination

  /C            Compress input file
  /U            Uncompress input file
  /I            Get compression info for input file
  source        Specifies the input file
  destination   Specifies the output file
Example to compress a file:

Code: Select all

SALCompressionCmd.exe /C SourceFile.txt DestinationFile.bin
Example to uncompress a file:

Code: Select all

SALCompressionCmd.exe /U SourceFile.bin DestinationFile.txt
Example to get compression info:

Code: Select all

SALCompressionCmd.exe /I SourceFile.bin
  Compression header:   Yes
  Has original data:    No
  Original size:        1500054
  Compressed size:      211176

When starting SALCompressionCmd.exe without parameters, the tool will show a GUI to select source and destination files.
There files can be compressed/uncompressed or get compression info.



A small sample how to use the API. It needs the SALCompression.dll.

When run in command (cmd) it will output this:

Code: Select all

Sample to compress a text string and uncompress it later
Text to compress : 'This is some text to compress'
The original bytes are: 54-68-69-73-20-69-73-20-73-6F-6D-65-20-74-65-78-74-20-74-6F-20-63-6F-6D-70-72-65-73-73
Compressing the bytes...
Bytes are compressed now.
The compressed bytes are: 3E-3C-00-02-F3-DC-1D-00-00-00-1C-00-00-00-90-54-68-69-73-69-73-10-73-6F-6D-65-74-65-78-12-74-74-6F-63-6F-6D-00-70-72-65-73-73
Uncompressing the bytes...
Uncompressed text : 'This is some text to compress'

The archive contains all sources.

The binaries can be found in the Binaries folder.

SALCompression.NET can be downloaded here: ... rch_mode=f
You do not have the required permissions to view the files attached to this post.
Dave Rabelink

Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Posts: 521
Joined: 10 Mar 2017, 08:46
Location: Chennai,India

Re: SALCompression.NET

Post by a_sivababu » 06 Jan 2021, 09:55

Thanks Dave for sharing this important information.

Siva A

Return to “Tools & Samples”

Who is online

Users browsing this forum: [Ccbot] and 0 guests