Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Anyone know of a way to check for valid path?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00192165
Message ID:
00192228
Views:
33
>Hi all,
>
>The problem is simple: If I have a stored path, something like:
>lcPath = 'C:\thisfolderdoesnotexist\nowhere'
>
>I'd like to check if the past exists or not.
>
>I checked functions included in FOXTOOLS.FLL and nothing really did the job. I don't think VFP 6 has a function for this yet, and I'm using VFP 5 for this project. I've been suggested to use arrays, etc.
>
>But before I start jack-hammering keys like crazy, wanted to do a check first.
>
>:(
>
>What do u propose to verify for its validity?
>

There are a couple of approaches you can take here. You can use ADIR() with the "D" for an attribute specifier; it works in most all cases except where there's more than one "." in one section of a folder name.

If you need to know if a folder is writable, try to create a file using FCREATE(), and trap the error if it occurs:
FUNCTION IsWritable
LPARAMETER cDirTOCheck
LOCAL cErrorRtn, cTempFileName, cPathTOCheck, lSuccess, nFH
cPathToCheck = ALLTRIM(cDirToCheck)
IF RIGHT(cPathToCheck,1) # '\'
   cpathToCheck = cpathToCheck + '\'
ENDIF
cTempFilename = SYS(3)
DO WHILE FILE(cPathToCheck + cTempFileName)
   cTempFileName = SYS(3)
ENDDO
cErrorRtn = ON('ERROR')
lSuccess = .T.
ON ERROR lSuccess = .F.
nFH = FCREATE(cPathToCheck + cTempFileName)
ON ERROR &cErrorRtn
IF lSuccess
   =FCLOSE(nFH)
   ERASE (cPathToCheck + cTempFileName)
ENDIF
RETURN lSuccess
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