The point I didn't get through, I think, but still want to stress is:
When you're confronted with files as they are and can't change the outset, not everything is lost and without any chances for a legacy FP application to refer to files by name, also short name. You don't always have to expect things that effectively lead to files being replaced by new files with the old long name, but different short name.
If you're confronted with situations like Joe described with editing via rename original to bak file and writing the modified file version with the old long name but getting a new short name, you will have to deal with the problem and better have the long name available that's not having the same risc.
Well, provided legacy FP only sees files by their short name and even calling shell commands like DIR won't show you the long names - or only the long names and no clue which short name correspsonds to them, then you still have Windows API to get the long filename from a short file name with the help of FoxTools and RegFn()/CallFn():
Code:
Set Library To Home()+"foxtools.fll" Additive
Local lnGetLongPathName, lcLongName
lnGetLongPathName = RegFn32("GetLongPathName", "C@CI", "I", "Kernel32")
lcLongName = Replicate(Chr(0),260)
lnLength = CallFn(lnGetLongPathName,"C:\Progra~2",@lcLongName,Len(lcLongName))
? lnLength
? Left(lcLongName, lnLength)
Not sure whether you have RegFn32 in FP 2.6, if not you should at least have RgFn within Foxtools.fll and that's available since at least FP 2.5, also see what the Hackers Guide has as example for legacy FP, especially:
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
hackfox.github.io
The main idea of this is you could determine long file names and store them for a more stable reference, though you may not need this, if your files are static and only get added to, never erased and overwritten or moved (copied) to a new directory not in chronological order, getting new short names, especially if some short names have ~2 or higher suffixes. Which means a non problematic situation is where each short file name of a directory only has ~1 suffix, then coyping all files elsewhere won't change that, as each file name beginning is unique.
So to circle back to the point I want to make: You're not necessarily lost with only storing short file names for file referencing, it depends on the outset and if you're having everything in your own hands just avoid long names. If not, this API function of Windows can help you to determine the long file names as a more stable identifier of files.
Then you only have the same trouble you have, when files are erased or renamed or moved, which you also have with long file names, if they are not static. All in all there is no stable id for files. File systems refer to files by (full) file name and I guess depending on the file system you have an id like a file GUID, but that's also gone, if a file is not moved, but copied somewhere else, getting a new entry in the filesystem TOC (table of content) and therefore a new ID, even if the stem name is the same. So the long file name is probably the most stable identifier and reference to a file you can store in a table. Things like a cryptographic checksum would even change with any file change, even if it's still the same file, just modified, so they are even less relevant as file identifier. The most valueable identifer for a file is its long fullpath name.
The inverse function GetShortPathName also exists and is used the same way, I spare to give the counter example, so when storing long file names for stable reference to files, you can use GetShortPathName to detemine the (currently) short file names to access the files with FP 2.6