Hello.
I'm making a frontend program that uses emulators to play games.
I have to use one that doesn't accept long filenames though...
How can I convert the whole path of a file to the same path written the short way?
(for example C:\Program files\test.txt --> C:\Progra~1\test.txt)
I don't want to use the first 6 characters of the filename and then add ~1 because it can be ~2 if you have 2 files with the same 6 first characters. And it doesn't have to do with sorting...

I think I should first check if there's a ??????~2.??? file. If not, then I know that the filename is ??????~1.???
What can I do when there are many?