Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check if file exists only in a particular place
Message
De
09/10/2007 02:46:12
 
 
À
08/10/2007 19:02:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01258744
Message ID:
01259633
Vues:
30
>>>>I was refering to yours modification. However Cetin's code has the same probem. It'll check if file 'EMPS.exe' exists anywhere along VFP search path. To check for a file in specific location, you can use SYS(2000) or ADIR()
>>>
>>>Tssk tssk:) I think you made a typo.
>>>
>>>lcFileName = "AlocalFile.txt"
>>>STRTOFILE("Are you sure?",m.lcfileName)
>>>
>>>? "Exists in search path",;
>>> FILE(m.lcfileName)
>>>? "Exists in the same folder where exe is",;
>>> FILE(forcepath(m.lcFileName,justpath(application.servername)))
>>>
>>>ERASE (m.lcFileName)
>>>
>>
>>Hi Cetin,
>>
>>My point is that FILE() function is not reliable when looking for files in specific place. It could find a file in EXE ignoring path provided or give false positive in the root of drive.
>>
>>CLEAR
>>
>>CD ("C:\temp")
>>MD temp2
>>
>>lcFilePath = FULLPATH("") + "\temp2"
>>lcFileName = "AlocalFile.txt"
>>STRTOFILE("Are you sure?", "temp2\" + m.lcFileName)
>>SET PATH TO (lcFilePath  )
>>
>>? "Exists in drive root", FILE(JUSTDRIVE(_VFP.servername) + "\" + m.lcFileName)
>>? "Exists in search path", FILE(m.lcfileName)
>>? "Exists in the same folder where exe is", ;
>>		FILE(forcepath(m.lcFileName,justpath(application.servername)))
>>
>>ERASE ("temp2\" + m.lcFileName)
>>RMDIR temp2
>>
>
>Sorry I can't see how that shows that it's unreliable checking at a specific path.
>Cetin

Actually File() is reliable IF you specify a non-empty path. File('yourpath\yourfile.dbf') will give the correct result. But both File('\yourfile.dbf') and File('yourfile.dbf') will give the WRONG result if yourfile.dbf is NOT in the root, but in another directory in the path. I prefer to always use Afile(temp,'\yourfile.dbf')>0 since it is ALWAYS reliable.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform