CardGetFileInfo function

This function retrieves information about a file, specifically its size and ACL information.


  _In_     PCARD_DATA      pCardData,
  _In_opt_ LPSTR           pszDirectoryName,
  _In_     LPSTR           pszFileName,
  _Inout_  PCARD_FILE_INFO pCardFileInfo,
  _Inout_  LPSTR           pCardFileInfo


  • pCardData [in]
    Context information for the call. For more information, see CardAcquireContext.

  • pszDirectoryName [in, optional]
    Name of the directory that contains the file. Set to NULL for root.

  • pszFileName [in]
    Logical File Name for the file of interest.

  • pCardFileInfo [in, out]
    Logical File Name for the file of interest.

  • pCardFileInfo [in, out]
    Address of a CARD_FILE_INFO structure.

Return value

Zero on success; otherwise, nonzero.


CardGetFileInfo fails if the specified file does not exist.

For more information about file sizes, see CardWriteFile.

The file information that is returned is in the following structure.

typedef struct _CARD_FILE_INFO {
    DWORD  dwVersion;
    DWORD   cbFileSize;

The file size that is returned is the size of the data in its uncompressed form. It is not the “size of the file on the card.” Therefore, the reported size of a newly created file may be zero, even if that file was created with a nonzero file size. Alternatively, it can be the size used at file creation.

If CardGetFileInfo is called on a nonexistent directory, an SCARD_E_DIR_NOT_FOUND error code must be returned.

If CardGetFileInfo is called on an unreadable file, an SCARD_W_SECURITY_VIOLATION error code must be returned

If the name that pszFileName or pszDirectoryName specified is longer than the maximum length for file/directory names, SCARD_E_INVALID_PARAMETER must be returned.


Target platform



Cardmod.h (include Cardmod.h)



Send comments about this topic to Microsoft