It is related to how DOS works with the FAT32 format. You needed to get the long filename (directory in this case) to a 8.3 (8 for directory) format.
Look up information for the GetShortPathName C++ convention.
Better methods exist, such as soulware's solution, but I went for the "quick and dirty" hack in true old-school Microsoft C++ fashion.
Robert Richmond