Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File()
Message
De
29/12/2003 16:38:05
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
29/12/2003 16:27:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: File()
Divers
Thread ID:
00862385
Message ID:
00862656
Vues:
19
>>>>placed this code before the if block
>>>>
>>>>lFileExists = File(xFile)
>>>>lFileExists returns .T. BUT the file DOES NOT EXIST and the debugger confirms that fact but the code in the trace skips the execution inside the if block !! ???
>>>
>>>FILE() returns .T. if the file is found in the CURDIR(), in any folder specified in SET PATH and also if a file of that name is bound into the executable.
>>
>>But he's building the path to the file, i.e. the xFile is supposed to contain a path. What's not clear is whether the directory really got created, and what's the actual filename. I've noticed that using addbs() in some versions used to add the final backslash even when there was one already, and that for building full paths ForcePath() is much more reliable. So my sure-fire method for finding, opening and read/writing files is
>>
>>
lcFullFile=fullpath(forcepath(lcFilename, lcLocation))
>>if not directory(lcLocation)
>>   md (lcLocation)
>>endif
>>if not file(lcFullFile)
>>  * create the file
>>endif
The "bound into the .EXE" "feature" burned me a few years back. Even if you explicitly specify the path, and the path/folder exists, and the file is NOT in the specified folder but IS in the .EXE, FILE() will return .T..

Forgot about that, because I never include a file I would be checking for - the ones I check for are usually logs, SaveAs-es, output files etc, or .ini files and such, and I never include those into the exe. I was just lucky.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform