Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File()
Message
De
28/12/2003 20:51:29
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: File()
Divers
Thread ID:
00862385
Message ID:
00862401
Vues:
13
Check the value of the entire path, whether it is a valid file. Sometimes you might forget the drive specifier at the beginning (or at least the backslash); sometimes you may have a missing backslash or a double backslash between the path and the filename.

You may want to debug the value of xFile after assigning it a value:
WAIT WINDOW "xFile = " + xFile
Also, I have heard comments that the file() function isn't always trustworthy (I used it myself, but found no problems). You may want to try adir() as an alternative. To do this, you would call adir() with the single file as the skeleton, and see whether the return value is equal to 1 (file exists) or 0 (no matching file).

>LOCAL cEmployeesFolder , xFile
>
>cEmployeesFolder = Addbs(Addbs(oApp.cEmployeeImagesFolder) + "_" + Transform(employees.Id))
>If Not Directory(cEmployeesFolder)
> Md (cEmployeesFolder)
>Endif
>
>xFile = cEmployeesFolder + "300x350.jpg"
>
>*-- For a file that does not exist this next test will fail
>*-- That is to say that the block is not executed
>If Not File(xFile)
> *-- This next line fails to execute when the var xFile does not exist
> xFile = Addbs(oApp.cEmployeeImagesFolder) + "camera.jpg"
>Endif
>
>BUT the watch window reports
> File(xFile) is .F.
> NOT File(xFile) is .T.
>
>
>Why would this happen ?
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform