Microsoft KB Archive/115236

{|
 * width="100%"|

INFO: Long Filenames on Windows NT FAT Partitions

 * }

Q115236

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * the operating system: Microsoft Windows NT, versions 3.5, 3.51, 4.0
 * the operating system: Microsoft Windows 2000

-

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 

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 Additional query words:

Keywords : kbAPI kbFileIO kbKernBase kbOSWin2000 kbDSupport kbGrpDSKernBase

Issue type : kbinfo

Technology : kbAudDeveloper kbWin32sSearch kbWin32API