# Obtain File Format Information

KeyView allows you to obtain the following basic information for a file:

- The character set. See the `KVCharSet` enumerated type.
- The class of document. See the `ENdocClass` enumerated type.
- The specific type of document. See the `ENdocFmt` enumerated type.
- Some other attributes such as the presence of encryption. See the `ENdocAttributes` enumerated type.

You can obtain the file format information by using the `fpGetFileInfo()` function pointer.

You call `fpGetFileInfo()` with the path to the file, and a pointer to a `KVDocInfo` structure that KeyView can fill with the file details. For more details about the `fpGetFileInfo()` function pointer, see C API Reference.

## Get the Types of Files in a List

The following example illustrates how to:

- obtain function pointers by calling `KVPDFGetInterface`. The pointer to this method is passed into the function as `fpGetInterface` in this example. You need this pointer to get other function pointers, including `fpInit()`, which must be called first, and `fpShutdown()`, which must be called last. For details of how to obtain this pointer, see Get a Session Context.
- initialize KeyView using `fpInit`.
- use the `fpGetFileInfo()` method for each path in an array of file names (`ppszFileNames` in this example). The file types output are put in the `peFileTypesOutput` array of enumerated type `ENdocFmt`.
- shut down KeyView by calling `fpShutdown()`.

NOTE: If a call to `fpGetFileInfo` is unsuccessful, the `KVDocInfo` structure is not modified. The return value of `fpGetFileInfo` is therefore ignored in this example because the `KVDocInfo` structure is left zero-filled with the character set equal to `KVCS_UNKNOWN`, the document class to set to `AutoDetNoFormat`, and the file type of `Unknown_Fmt`.

    #include "kvpdf.h"

    void getTypesOfFilesInList(
        const KVPDFInterface sInterface,
        const char* const pszKeyViewDir,
        const char* const pszTempFolder,
        const char* const * const ppszFileNames,
        ENdocFmt* const peFileTypesOutput,
        const unsigned int numberOfFiles)
    {
        KVPDFContext context = NULL;
        unsigned int i = 0;

        if(sInterface.fpInit(
                pszKeyViewDir, pszTempFolder, &context
            ).eErrorCode != KVERR_Success)
        {
            return;
        }

        for (i = 0; i < numberOfFiles; i++)
        {
            // (ENdocFmt) 0 = Unknown_Fmt
            KVDocInfo sDocInfo = {0};
            sInterface.fpGetFileInfo(context, ppszFileNames[i], &sDocInfo);
            peFileTypesOutput[i] = sDocInfo.adInfo.eFormat;
        }

        sInterface.fpShutDown(&context);
    }

_FT_HTML5_bannerTitle.htm