Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find Files by Program
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00484302
Message ID:
00484423
Vues:
13
Hi Zahid,

I wanted to suggest it to, but haven't found it on my home computer. Here it is:
********************************************************************
*  Description.......: FindFileInNetwork
*  Calling Samples...: FindFileInNetwork("pdfmon.dll","c:\")
*  Parameter List....: tcFileToSearch, tcSearchPath, tlEntireNetwork
*  Created by........: Houston Brennan 06/13/2000
*  Modified by.......: Nadya Nosonovsky 06/16/2000 11:30:52 AM (with assistance of BP and JH)
********************************************************************
lparameters tcFileToSearch, tcSearchPath, tlEntireNetwork
** Check passed parameters
if vartype(tcFileToSearch)<>'C' or empty(tcFileToSearch)
     return .f. && First parameter is required
endif
#define NoAttributesSet       0
#define readonly              1
#define hidden                2
#define system                4
#define Archived              32
#define DoNotSearchSubFolder  0
#define SearchSubFolder       1

local lcRetPath, lcDrive, lcSearchPath, lnStartTime,;
     lcPrevOnEsc, lcPrevEscape, MsgTail, halt, loFiler

lcRetPath=''
* note clock reading for generating final timing statistics
lnStartTime = seconds()                         && # seconds since midnight

* support user Escapes for interrupting the loop
lcPrevOnEsc = on('escape')                    && save previous Escape handler
lcPrevEscape = set('escape')                    && previous Escape enablement state
set escape on                                   && enable escape handling
halt = .f.                                        && allow loop to run until this flag is toggled
on escape halt = .t.                         && force immediate termination if user escapes

* assemble fixed portion of status bar message outside of loop, for speed
MsgTail = "...         Wait or press Esc to cancel ..."

wait window nowait 'Searching file '+tcFileToSearch+iif(tlEntireNetwork,' in the whole network...',' ...')
loFiler = createobject( "Filer.FileUtil" )
loFiler.FileExpression = tcFileToSearch
loFiler.SubFolder = SearchSubFolder && Search all tree

if vartype(tcSearchPath)<>'C' or (empty(tcSearchPath) and !tlEntireNetwork)
     lcSearchPath='c:\' && Local drive
else
     lcSearchPath=tcSearchPath
endif
if !tlEntireNetwork && Only specified path to search
     loFiler.SearchPath = lcSearchPath
     set message to 'Searching in '+lcSearchPath + MsgTail
     loFiler.find(0) && Perform search
     if m.halt or lastkey()=27 && Escape was pressed
          exit
     endif
     if loFiler.files.count>0 && At least one file was found, pick up the first
          lcRetPath=loFiler.files.item[1].path
     endif
else
     local lni, lcDrive
** Want to search in the whole network
     for lni = 67 to 90
          lcDrive = chr(lni)
          if inlist(drivetype(lcDrive),3,4)
* Make sure the drive is ready (type 4 is either removeable or a network drive)
               set message to 'Searching drive '+lcDrive+MsgTail
               loFiler.SearchPath = lcDrive+':\'
               loFiler.find(0) && Perform search
               if m.halt or lastkey()=27 && Escape was pressed
                    exit
               endif
               if loFiler.files.count>0 && At least one file was found, pick up the first
                    lcRetPath=loFiler.files.item[1].path
                    exit
               endif
          endif
     endfor
endif
* Restore settings
if lcPrevEscape='OFF'
     set escape off
endif
on escape &lcPrevOnEsc
set message to ' '
wait clear
=messagebox("File "+iif(!empty(lcRetPath),lcRetPath+tcFileToSearch,"not")+" found in "+ ;
           alltrim(str(seconds()-lnStartTime,10,3))+" sec.")
return lcRetPath && Path to the first found file
>I assume this is something you want to do in your program rather than on a one-time basis. If so, rather than use a PRG to do the search, I would take advantage of the filer tool. It does not ship with all versions of VFP, but if you have it, it's a real timesaver. Look up filer.dll in the VFP help file.
>zahid
>
>>I need to made a program that find a Table (dbf) in a computer, i don´t know path or drive.
>>
>>Some Idea where could i begin ?
>>
>>Im reading about windows API but ?
>>
>>Thanks and Regards
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform