Structure of paths and filenames

This topic describes the structure of path and the components of a filename.

A full filename consists of four components:

  • the drive: a single letter followed by a colon.

  • the path, starting with a backslash and ending with the final backslash in the name. The backslashes divide the path into components.

  • the file name: everything from the character following the last backslash to the character preceding the final dot.

  • the extension, which consists of everything after the final dot.

In "8.3" filing systems such as FAT, the meanings of these components are well understood. In non-8.3 systems, the mapping is straightforward, except for the split of the final component of the name between filename and extension. The rule is that anything following the final dot of this component is the extension, anything preceding it is the filename. If there is no dot, or nothing after the final dot, the entire component is the filename, and there is no extension.

The following table shows some sample filenames and their component parts:

Full name

Drive

Path

Filename

Extension

d:\path\fn.ext

d:

\path\

fn

.ext

autoexec.bat

   

autoexec

.bat

c:\readme

c:

\

readme

 

c:readme

c:

 

readme

 

.profile

     

.profile

..

   

..

 

Note that not all parts need be present. Note also that the directory navigators .. and . are not an intrinsic part of the file system model, and are not therefore supported directly in names.

A directory is identified by a trailing slash: thus, c:\wrd\ indicates a directory, but c:\wrd indicates a file with no extension. This mandatory requirement allows parsing to function without ambiguity, and also without reference to any session with the file server.

The classes described here are used to handle all filename parsing requirements in a uniform way. Because they handle the logic consistently, and because this logic contains some subtle rules, you should always use them rather than writing your own code.