INFO: Using Long file and Printer Names with 32-bit Versions of Windows

ID: Q232269


The information in this article applies to:


SUMMARY

Applications must manage long file and printer names correctly to be fully compatible with 32-bit versions of Windows. Operating system support for long file and printer names is consistent across all file systems supported by the various 32-bit Windows platforms.


MORE INFORMATION

As file systems and operating systems become more complex, the need to support long file and printer names is increasingly important. Long file names can be up to the globally defined constant MAX_PATH characters in most cases. Exceptions to this maximum are noted in the SDK for relevant functions. For example, CreateDirectory takes a default string size limit of 248 characters.

The following guidelines apply to all file systems supported by the various 32-bit Windows operating systems:

  • A name can contain any character except a path separator, a character in the range 0 through 31, or any character not allowed by the file system. A name can also contain characters in the extended character set (128–255).


  • Use the backslash (\), the forward slash (/), or both to separate components in a path.


  • 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 components in a directory name or filename.


  • The following characters are reserved for Windows, and should not be used in directory or file names:
    
    < > : " / \ | 
  • Don't use reserved words, such as aux, con, and prn, as file or directory names.


  • Don't assume case sensitivity, because not all file systems distinguish between case.


  • The maximum length for a path is given by MAX_PATH, including the drive, path, file extension, and NULL terminator.

    Note: On Windows NT, the Unicode versions of the CreateDirectory, FindFirstFile, GetFileAttributes, and SetFileAttributes functions allow paths to exceed the MAX_PATH length if the path has the \\?\ or \\?\UNC\ prefix. These prefixes turn off path parsing. Use the \\?\ prefix with paths for local storage devices and the \\?\UNC\ prefix with paths having the Universal Naming Convention (UNC) format. An example of a UNC path is \\machine\sharename.

  • REFERENCES

    For more information about supporting long file names, consult the Files and I/O information in the Base Services section of the Platform SDK Documentation.

    Additional query words: compatguidestability

    
    Keywords          : kbKernBase kbWinOS2000 kbSDKPlatform kbSDKWin32 
    Version           : WINDOWS:
    Platform          : WINDOWS 
    Issue type        : kbinfo 

    Last Reviewed: June 23, 1999