private void Encode()
 {
     target = CreateEncoder();
     target.Encode();
     inputStream.Dispose();
     outputStream.Dispose();
 }
        private static void Encode(Stream inputStream, Stream outputStream)
        {
            var encoderInput = new StreamEncoderInput(inputStream);
            var encoderOutput = new StreamEncoderOutput(outputStream);
            var codeTable = new FrameworkDictionaryCodeTable(1000);
            var encoder = new LzwEncoder(encoderInput, encoderOutput, codeTable);

            encoder.Encode();
            outputStream.Flush();
            outputStream.Seek(0, SeekOrigin.Begin);
        }
        private byte[] Encode(byte[] dataToEncode)
        {
            using(var encoderInputStream = new MemoryStream(dataToEncode))
            {
                using(var encoderOutputStream = new MemoryStream())
                {
                    var input = new StreamEncoderInput(encoderInputStream);
                    var output = new StreamEncoderOutput(encoderOutputStream);
                    ICodeTable codeTable = new FrameworkDictionaryCodeTable(10000);
                    var encoder = new LzwEncoder(input, output, codeTable);

                    encoder.Encode();

                    return encoderOutputStream.ToArray();
                }
            }
        }