Filename Conventions

Although each file system can have specific rules about the formation of individual components in a directory or filename, all file systems follow the same general conventions: a base filename and an optional extension, separated by a period. For example, the MS-DOS FAT file system supports 8 characters for the base filename and 3 characters for the extension. This is known as an 8.3 filename. The FAT file system and NTFS support filenames that can be up to 255 characters long. This is known as a long filename. To get an MS-DOS filename given a long filename, use the GetShortPathName function. To get the full path of a file, use the GetFullPathName function.

Both file systems use the backslash (\) character to separate directory names and the filename when forming a path.

General rules for applications creating names for directories and files or processing names supplied by the user include the following:

  • Use any character in the current code page for a name, but do not use a path separator, a character in the range 0 through 31, or any character explicitly disallowed by the file system. A name can contain characters in the extended character set (128pics/WIN3200090000.gif255).

  • Use the backslash (\), the forward slash (/), or both to separate components in a path. No other character is acceptable as a path separator.

  • Use a period (.) as a directory component in a path to represent the current directory.

  • Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory.

  • Use a period (.) to separate the base filename from the extension in a directory name or filename.

  • Do not use the following characters in directory names or filenames, because they are reserved for Windows:

< > : " / \ |

  • Do not use device names, such as aux, con, and prn, as filenames or directory names.

  • Process a path as a null-terminated string. The maximum length for a path, including a trailing backslash, is given by MAX_PATH.

The wide (Unicode) versions of the CreateDirectory, FindFirstFile, GetFileAttributes, and SetFileAttributes functions permit paths that exceed the MAX_PATH length if the path has the "\\?\" or "\\?\UNC\" prefix. These prefixes direct the functions to turn off path parsing. Use the "\\?\" prefix with paths for local storage devices and the "\\?\UNC\" prefix with paths having the Universal Naming Convention format.

  • Do not assume case sensitivity. Consider names such as OSCAR, Oscar, and oscar to be the same.

By following the rules listed in this section, an application can create valid names for files and directories regardless of the file system in use.

Long Filenames on Windows NT

The operating system stores the long filenames on disk as special directory entries. When you create a long filename, the operating system creates a corresponding short 8.3 form of the name.

The operating system stores the long filenames on disk in Unicode. This means that the original long filename is always preserved, even if it contains extended characters, and regardless of the code page that is active during a disk read or write operation. The case of the filename is preserved, but the file system is not case-sensitive.

The valid character set for these long filenames is the NTFS character set, less one character: the colon (':') that NTFS uses for opening alternate file streams. This means that you can freely copy files between NTFS and FAT partitions without losing any file name information.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database