Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Expertise: Beginner
Aug 6, 1997

Comparing Long And Short File Names

When you reference files in Windows 95, you may encounter situations when 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 searching for a specific file and do not know if it will be given in a long or short format. For example, Dir$() will always return a long file name, but the file you are comparing it to may be entered by a user as either a long or short name. To compare two file names on a level field, you must change them both to short or to long. Dir$() returns a long file name, so you can take advantage of it as a built-in file name converter. What a plus! Pass it C:\PRIVAT~1\MYSTUF~1\NEWTEX~1.TXT and it will return NEW TEXT DOCUMENT.TXT. The only hitch is that you do not 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 and let Dir$() convert each subdirectory. After you get the long file name from the path, call Dir$(" C:\PRIVAT~1\MYSTUF~1") and get My Stuff back. With each successive call, take the long names that were returned and concatenate them into a full path string. This process will work even if you begin with a long file name and path.
MicroHelp Uninstaller
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date