Use this function to find the first file or subdirectory in a specified directory.

First call f_findfirst() and then, if the file is found, get the next file with f_findnext(). Files with the system attribute set are ignored.

Note: If this function is called with "*.*" and it is not the root directory:

  • The first entry found will be ".", the current directory.
  • The second entry is “..”,  the parent directory.


int f_findfirst (
    const char *   filename,
    F_FIND *       find )


Argument Description Type
filename The name of the file to find. char *
find Where to store the find information. F_FIND *

Return values

Return value Description
F_NOERR Successful execution.
Else See Error Codes.


void mydir()
    F_FIND find;
    if (!f_findfirst( "A:/subdir/file*.*", &find ))
            printf( "filename:%s", find.filename );
            if (find.attr&F_ATTR_DIR)
                printf( " directory\n" );
                printf( " size %d\n", find.filesize );
        while (!f_findnext( &find ));