Filter in File or Stream Mode

To filter a file or stream

  1. Instantiate a LicenseInfo object to store your KeyView license.

    LicenseInfo myLicense = new LicenseInfo("my_organization", "my_key");
  2. Instantiate a Filter object, providing your LicenseInfo object.

  3. Set the location of the Filter libraries by setting the FilterDirectory property. These libraries are provided in the directory PLATFORM\bin, in the KeyView Filter SDK, where PLATFORM is the name of the platform. For example:

    objFilter.FilterDirectory = "C:\\KeyviewFilterSDK\\WINDOWS_X86_64\\bin";
  4. Set the input source as either a file or input stream by calling the SetInputSource method.

    objFilter.SetInputSource(m_inFile);
  5. Filter the file or stream by calling either the FilterTo or DoFilterChunk method. The FilterTo method extracts the data to a file or a stream. The DoFilterChunk method extracts one chunk of data from a file or a stream. It must be called repeatedly until the entire buffer is filtered.

    If filtering in file mode, use the following code:

       {
         m_objFilter.filterTo(m_extractDir + filename + m_extension);
       }

    If filtering in stream mode, use the following code:

        {
         outf = new File(m_extractDir + filename + m_extension);
         fos = new FileOutputStream(outf);
         m_objFilter.filterTo(fos);
         fos.close();
        }
  6. Terminate the filtering session and free allocated system resources by calling the ShutdownFilter() method. This must be called within a Finally block.

    m_objFilter.ShutdownFilter();
_FT_HTML5_bannerTitle.htm