Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Anyone know of a way to check for valid path?
Message
From
27/02/1999 14:43:41
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00192165
Message ID:
00192373
Views:
18
does the following work as well?
mytest = lcPath + "\nul.txt"      && nul.txt should exist in every directory!
if file(mytest) then && dir exists
    copy file (myhappyfile) to (lcPath)
else
    md lcPath
    copy file (myhappyfile) to (lcPath)
endif
>>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
--Todd Sherman
-Wake Up! Smell the Coffee!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform