Xceed Binary Encoding Library Documentation
Encoding and decoding from file to memory (C# example)
Examples > Encoding and decoding from file to memory (C# example)

This sample encodes with the Base64 format from a file to memory and decodes the encoded data from memory to a file.

C# Copy Code

XceedBinaryEncodingLib.XceedBinaryEncoding encoder = new XceedBinaryEncodingLib.XceedBinaryEncodingClass(); 

encoder.License( @"your license key" );      

try
{
  encoder.EncodingFormat = new XceedBinaryEncodingLib.XceedBase64EncodingFormatClass();        

  object bytesRead = null; 

  // Read the data from the file and encode it to memory
  object encodedData = encoder.ReadFile( @"c:\test\file.txt",
               0,0,XceedBinaryEncodingLib.EXBFileProcessing.bfpEncode ,true, ref bytesRead ); 

  // Decode the encoded data located in memory to file
  encoder.WriteFile( ref encodedData, XceedBinaryEncodingLib.EXBFileProcessing.bfpDecode,
                     true, @"c:\test\decoded.txt", false );       
}
catch( System.Runtime.InteropServices.COMException except )
{
  MessageBox.Show( except.ToString() );
}