Why Can I Not Store More Files in My Folder on a FAT32 Formatted USB Drive?

Updated Jun 5, 2018

Reported In

Software

  • LabVIEW

Issue Details

When I run my VI which logs data to file on a USB drive which is FAT32 formatted it consistently stops logging after it has written 21,844 files. The VI continues to run but no files are added to the USB drive even though the USB drive is not anywhere near full capacity. How can I store more files to the USB drive?

Solution

A FAT32 directory can have 65,536 directory entries. Each file and subdirectory takes from 2 to 13 entries, depending on the length of its name. It is not possible to change the maximum number of entries a directory can store. The only solution is to split the logged files into multiple directories (possible using a timestamp).

Attached to this KB are 2 VIs which both store 50,000 files containing a random number. The VI called ManyFiles-SingleFolder stores all 50,000 files to a single directory. If this VI is run specifying a USB FAT32 folder a maximum of 21,844 files will be created. The VI called ManyFiles-MultipleFolders stores all 50,000 files to multiple directories with the folder names specified by the current hour and minute of when the files were stored. When this VI is run and the total number of files is counted, all 50,000 files are found to have been stored.

Below are the VI snippets for both of the attached VIs: