Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Filesearch
Message
 
À
13/07/2008 06:08:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
01330920
Message ID:
01330959
Vues:
22
>How can I search a particular file say "abc.ini", which may be hidden & may also be in hidden folder. The file may be anywhere in the whole c: drive. Only one occurance of the file will be there. I want to do this from program & dont want to use filer.
>
>I need the full path of the file.
>
>Thanks in advance

Here, I already posted this in other form, but post it here, just because someone else mat need it:
(keep in mind that THIS search for FIRST occurrence of the file and then stops)
SET ASSERTS ON
CLEAR
? FileSearch([c:\],[abc.ini])


FUNCTION FileSearch(lcFolder,lcFileName)
   IF FILE(lcFileName)
      RETURN FULLPATH(lcFileName) && If the file is in the VFP internal search path why we should bother? Just return it
   ENDIF

   LOCAL lnFiles, laFiles, lnFor, laFiles[1]
   IF TYPE([lcFileFind]) == [C] AND NOT EMPTY(lcFileFind)
      RETURN lcFileFind
   ENDIF
   IF TYPE([lcFileFind]) == [U]
      PRIVATE lcFileFind
   ENDIF
   
   lcFileFind = []
   lnFiles = ADIR(laFiles,lcFolder+[*.*],[HSD])
   FOR lnFor = 1 TO lnFiles
       IF (laFiles[lnFor,1] == [.]  OR;
           laFiles[lnFor,1] == [..]) AND;
           [D] $ laFiles[lnFor,5]
          LOOP
       ENDIF
       IF [D] $ laFiles[lnFor,5] AND EMPTY(lcFileFind)
          lcFileFind = FileSearch(lcFolder+ADDBS(laFiles[lnFor,1]),lcFileName) 
       ENDIF
       IF NOT EMPTY(lcFileFind)
          EXIT
       ENDIF
   NEXT
   IF EMPTY(lcFileFind)
      DIMENSION laFiles[1]
      lnFiles = ADIR(laFiles,lcFolder+lcFileName,[HS])
      IF lnFiles # 0
      ASSERT .f.
         lcFileFind = lcFolder+lcFileName
      ENDIF
   ENDIF
RETURN lcFileFind 
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform