VB example VB streaming example VC++ example Delphi example C# example VB.NET example
In the descriptions below, you can freely replace the word "encode" with "decode" in order to find out how to decode data, because encoding and decoding work exactly the same way.
To encode data from a file directly into memory, perform the following 4 steps. Put the Xceed Binary Encoding control on a form or instantiate it, then:
Specify the format for the resulting encoded data. To do this, set the EncodingFormat property.
Tell the library to encode. To do this, call the ReadFile method, passing the source filename, a destination memory buffer and specifying True for the bEndOfData parameter.
Obtain the encoded data. To do this, assign the return value of the ReadFile method to the variable of your choice.
Make sure that everything worked properly. To do this, use your language's error handling object or error handling capabilities. The Xceed Binary Encoding Library supports standard COM error handling functionality.
To encode data from a file directly into memory, in portions instead of the complete file, perform the following 7 steps. Put the Xceed Binary Encoding Control on a form or instantiate it, then:
Specify the format for the resulting encoded data. To do this, set the EncodingFormat property.
Determine the size of the file you will encode.
Tell the library to encode some data from the file. To do this, call the ReadFile method for each portion of data, passing the source filename, a destination memory buffer and specifying False for the bEndOfData parameter. Provide a starting offset of 0, and the size you specify should be the amount of data you want the library to encode during the first pass. You can use for example 32768 bytes per portion.
Accumulate the encoded data. To do this, append the data returned by the ReadFile method to a variable which contains the complete encoded memory buffer so far. You can also process the compressed data as it is returned by the library or pass it to other streaming methods.
Increment your current offset. The ReadFile method returns the amount of bytes read via the lBytesRead parameter. Add this amount to your offset.
Continue telling the library to encode data from the file until the your offset reaches the file's size. If your offset is smaller than the file size, call the ReadFile method, setting bEndOfData to False and passing the same filename, your new offset, and your portion size. If your offset has reached the file's size, call the ReadFile method with bEndOfData set to False, 0 for offset, 0 for file size, and if you want, an empty filename. In this case processing is complete.
Make sure that everything worked properly. To do this, use your language's error handling object or error handling capabilities. The Xceed Binary Encoding Library supports standard COM error handling functionality.