MS-DOS arranges and stores file-system contents in directories. Every file system has at least one directory, called the root directory, and may have additional directories either in the root directory or ordered hierarchically below it. The contents of each directory are described in individual directory entries. MS-DOS strictly controls the format and content of directories.
The root directory is always the topmost directory. MS-DOS creates the root directory when it formats the storage medium. The root directory can hold information for only a fixed number of files or other directories, and the number cannot be changed without reformatting the medium. A program can identify this limit by examining the dpRootDirEnts field in the DEVICEPARAMS structure returned by Get Device Parameters (Interrupt 21h Function 440Dh Minor Code 60h). This field specifies the maximum number of root-directory entries for the medium.
MS-DOS keeps track of a current directory for each logical drive. The current directory is the default directory MS-DOS uses whenever a program specifies a file without giving a full path. A program can identify the current directory for a drive by using Get Current Directory (Interrupt 21h Function 47h). It can set the current directory for a drive by using Change Current Directory (Interrupt 21h Function 3Bh). Note that changing the current directory for a drive does not change the current drive.
A program can generate a complete list of the directories on a given drive (the directory tree) by using Find First File (Interrupt 21h Function 4Eh) and Find Next File (Interrupt 21h Function 4Fh). If the program specifies the attribute ATTR_DIRECTORY when it calls these functions, they return information about directories as well as files. To generate a complete tree, the program must start the search in the root directory and recursively search each directory it finds.