Share via


File Extensions

A file extension is the part of a file name that comes after the final period. For example:

readme.txt
movie1.dvr-ms
Animal.Mammal.Rodent.Mouse.Data
Performance Analysis for January 1.report
datafile

The first four examples have the file extensions .txt, .dvr-ms, .Data, and .report, respectively. The last file has no extension.

Files that contain a particular type of data commonly have the same file extension; file extensions are used to hint at the type of data a file contains. The Shell uses file extensions to determine a file's type, and file types are the basis for file associations, though which the Shell determines how to handle files of a particular type. For more information about file types, see File Types.

Multiple periods may be used in a file name, but only those characters following the final period are recognized as a file name extension; everything that precedes the final period is considered part of the file's name.

Note  Although file names can contain spaces, extensions cannot. Extensions should also not use characters beyond the standard ASCII set (>=127).

The Shell Lightweight Utility Functions library provides a function, PathFindExtension, which can be used by applications to find the file extension for a specified file name or path.

A file extension is meant to be treated as a hint about a file's contents. A file extension suggests, but does not guarantee, that a file contains a particular type of data or format.

Long vs. Short File Extensions

File names in the 8.3 format (that is, a file name of one to eight characters, separated by a period from an extension of up to three characters) are an artifact from the days of Microsoft MS-DOS. For example command.com and config.sys are file names in 8.3 format. Older file names that use the 8.3 format often cause file names to appear cryptic. Support for long file names was introduced in Microsoft Windows 95 and Microsoft Windows NT version 3.51. All current Windows file systems (FAT16, FAT32, and NTFS) support long file names.

File name extensions that use only three characters are commonly called short extensions. A long extension is any extension longer than three characters.

Note  New extensions should always be defined as long extensions. There is almost no reason whatsoever to define a short file extension, and many reasons against.

In addition to causing cryptic file names, the limited length of short extensions increases the probability of an extension collision. An extension collision occurs when files that contain different types of data are identified by the same extension. Long extensions are preferred over short extensions because they decrease the chances of an extension collision, and users tend to understand them more easily.

It is no longer recommended that you define both a short and long file name extension for a file type. Instead, define only a long file name extension. The long extension is not limited to a specific number of characters, but you should still make it concise. At the minimum, you should append a vendor abbreviation. For example, you can expand the short file extension .doc to the long extension .doc-msword.