INFO: File Change Notifications May Contain Either Short or Long File Names (290601)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000
    • the operating system: Microsoft Windows XP

This article was previously published under Q290601

SUMMARY

An application must be able to deal with both long and short file names when the application processes file change notifications through the ReadDirectoryChangesW() API.

MORE INFORMATION

The method by which a file is accessed determines the name that is reported in the file change notification. For example, if the file is deleted through the DeleteFile() API with a long file name specified in the lpFileName parameter, the delete notification will contain the long file name. But if the short file name is used when the file is deleted, the notification will contain the short file name.

The command interpreter that is included with Microsoft Windows NT, Microsoft Windows 2000, and Microsoft Windows XP commonly referred to as the command prompt or Cmd.exe, performs most operations using long file names. However, the del command uses the short file name, if present, to delete a file. Programs should therefore anticipate receiving short file names for some delete operations.

When a delete notification is received, it is not possible to use the Win32 APIs to determine the long file name from the short file name because the file has already been deleted. An application would need to keep a cache of both short and long file names to match them up when the notification is received.

Modification Type:MinorLast Reviewed:6/23/2005
Keywords:kbAPI kbFileIO kbinfo kbKernBase KB290601