# OpenSC API Reference

sc_select_file
3
opensc

# sc_select_file

Select a file on a smart card

## Synopsis

    #include <opensc.h>

    int sc_select_file(sc_card_t *card,
                       const sc_path_t *path,
                       sc_file_t **result);

## Description

This function selects the file specified by path. If path specifies a file within the currently selected DF, sc_select_file() will not select the MF first, but interpret the path relative to the current DF. It does this in order to prevent losing any authorizations previously established with the card (e.g. by presenting a PIN).

If result is not NULL, an sc_file_t object is created, and the pointer to this object is stored in the location pointed to by result. This handle should later be released using sc_file_free().

## Return value

If an error occurred, a negative error code is returned. Otherwise, the function will return 0.