Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper Case File Names vs. ADIR()
Message
 
To
10/11/1997 17:07:38
Murray Mcintosh
Mammography Reporting System, Inc.
Seattle, Washington, United States
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00058492
Message ID:
00059488
Views:
34
>>>>Does anyone know an easy way yo use the APIs to retrieve file names in their "true" case (upper and lower, the same way we see them in Windows Explorer)? I want essentially the functionality that ADIR() achieves, but that VFP function returns all upper case.
>>>>
>>>>TIA,
>>>>
>>>>-- Randy
>>>
>>>Randy,
>>>
>>>Try this:
>>>
>>>DECLARE SHORT GetFileTitle IN COMDLG32;
>>> STRING @lpszFile, STRING @lpszTitle, SHORT cbBuf
>>>
>>>lpszFile is the file or directory name you want the actual case for.
>>>lpszTitle is a buffer large enough to hold the information.
>>>cbBuf is the size of the buffer.
>>>
>>>For example:
>>>
>>>lcfile = "C:\ANYFILE.TXT"
>>>lcbuffer = SPACE(200)
>>>lnsize = LEN(lcbuffer)
>>>= GetFileTitle(@lcfile, @lcbuffer, lnsize)
>>>
>>>With directories, be sure to strip off the end backslash if it exists.
>>
>>George,
>>
>>Looks promising. I take it you would just continue using ADIR() and then calling this function for each file in the array. That should be fast enough.
>>
>>Thanks for the reply.
>>
>>-- Randy
>
>This is a function that would be useful to me, however when I try the GetFileTitle example, lpszTitle does not end up in the case as it shows up in Windows Explorer (or by doing a dir in a dos window). If lcfile is in upper case, lpszTitle ends up in proper case, otherwise lpszTitle ends up in whatever case lcfile was when I called the function. I'm using VFP 5.0a with Window NT 4.0.
>
>Has anyone gotten this to work??

Murray,

Neither the Explorer nor DOS always showns a file in the same case as it was created. For example, files on my Novell 3.12 server are displayed in upper and lower case, even though Novell can't store the names in that fashion. Local files are different, even so, DOS may or may not display them properly, depending on how the were created. For example, if you create a child directory in mixed case, if you list it from the parent, it will show in all upper case, change to it, and it's displayed as it was created. However, file names are always listed by DIR in upper case regardless. However, in the Explorer, it should display the name as it was actually created.

GetFileTitle seems to make its decision based on how the name is supplied to it. Send it all upper case, it comes back proper, send it all lower it comes back in lower case. Send it mixed, with the stem in lower and the extension in upper and you get back extactly what you sent.

Here's what the documentation says, "...the GetFileTitle function retrieves the same text that the system would compose in displaying a filename to the user. This text is intended to be used for display purposes only and is in accordance with the user's preferences for display of filenames."

hth,

George
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform