Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getfile question
Message
From
31/03/2000 17:45:00
 
 
To
31/03/2000 16:02:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00353361
Message ID:
00353696
Views:
20
>>Question: IF a user doesn't select a file - but rather types in a non-existent file name - an error is generated. How should I verify that the filename they typed in (for the users that don't simply select the file) is a file that exists in the app directory.
>
>To add a qualifier to Mark's suggestion...since FILE() will return .T. if the file lies anywhere on the path, you probably what to check with the explicit path that's allowed.
>
>For example:
>
>lcFile = GETFILE( [etc.])
>
>lcTemp = JUSTFNAME( lcFile )
>lcDir = ?sys(5)+sys(2003)+'\'
>

save a little effort - FULLPATH(CURDIR()) will return the current directory properly prefixed without the ambiguity that I've seen arise from using SYS(5) on UNCs where you're working in an unmapped UNC, and terminates cleanly with the \ in all cases. YMMV - I avoid SYS(5) like the plague. You can also force the return from GETFILE to specify a FULLPATH() IAC, so the following is better form from my POV at least:

lcFile = FULLPATH(GETFILE(blah, blah, woof, woof))
? FILE(lcFile) && never an ambiguity!!!
? FULLPATH(CURDIR()) == JUSTPATH(lcFILE)+'\' && is it here in the current dir?

>IF FILE( lcDir + lcTemp )
> *!* Then you have a valid file
>ENDIF
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform