INFO: Long Filenames on Windows NT FAT Partitions

Last reviewed: November 26, 1997
Article ID: Q115236
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows NT versions 3.5, 3.51, 4.0

SUMMARY

Windows NT, versions 3.5, 3.51, and 4.0 have the ability to create or open files with long filenames (LFN) on Windows NT file allocation table (FAT) partitions.

UNICODE is stored on disk, so that the original name is always preserved for extended characters regardless of which code page happens to be active when reading from or writing to the disk.

The legal character set is that of the Windows NT file system (NTFS) (except for the ":" for opening NTFS alternative file streams), so you can copy arbitrary files between NTFS and FAT without losing any of the filename information.

MORE INFORMATION

The LFNs are not available from the MS-DOS DIR command, but they are available from the Windows NT DIR command. When you create an LFN on a Windows NT FAT partition, an accompanying short name is created just as on an NTFS partition. You can access the file or directory with either the long names or the short names under Windows NT.

For example, use the Microsoft Editor (MEP) to create a file named as follows on a FAT partition under Windows NT:

   longfilename.fat

This is exactly how the filename appears when you run the DIR command from the Windows NT command prompt. However, when you boot the machine into MS- DOS and run the DIR command, the filename appears as follows:

   longfi~1.fat

NOTE: NTFS partitions are not available under MS-DOS, so you cannot perform this experiment using an NTFS partition.

The same result can also be achieved programmatically. Build and run the following sample code on Windows NT:

Sample Code

   #include <windows.h>

   void main( )
   {
      WIN32_FIND_DATA fd;
      char buf[80];

      FindFirstFile( "long*", &fd );
      wsprintf( buf, "File name is %s", fd.cFileName );
      MessageBox( NULL, buf, "Test", MB_OK );
      wsprintf( buf, "Alternate file name is %s", fd.cAlternateFileName );
      MessageBox( NULL, buf, "Test", MB_OK );
   }

The first message box will read:

   File name is longfilename.fat

The second message box will read:

   Alternate file name is longfi~1.fat
Keywords          : BseFileio
Version           : WINNT:3.5,3.51,4.0;
Platform          : winnt
Issue type        : kbinfo


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 26, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.