devxlogo

Comparing Long And Short File Names

Comparing Long And Short File Names

When you reference files in Windows 95, you may encounter situationswhen you are unsure whether you’re working with a long or short file name.This becomes a problem if you are comparing file names or if you are searchingfor a specific file and do not know if it will be given in a long or shortformat. For example, Dir$() will always return a longfile name, but the file you are comparing it to may be entered by a useras either a long or short name.To compare two file names on a level field, you must change them bothto short or to long. Dir$() returns a long file name, so you can take advantageof it as a built-in file name converter. What a plus! Pass it C:PRIVAT~1MYSTUF~1NEWTEX~1.TXTand it will return NEW TEXT DOCUMENT.TXT. The only hitch is that you donot get the path, so you must pass Dir$() to each directory in the path,one by one. To do this, loop backwards through the full path string andlet Dir$() convert each subdirectory. After you get the long file namefrom the path, call Dir$(” C:PRIVAT~1MYSTUF~1″) and get MyStuff back. With each successive call, take the long names that were returnedand concatenate them into a full path string. This process will work evenif you begin with a long file name and path.

devx-admin

Share the Post: