>local intFileCount, strPath >with thisform >.filefinder.cFileExpression = oApp.ProdExe >.filefinder.cSearchPath = "c:\" >.filefinder.find(0) >if vartype(.filefinder.oFiles) == "O" then >messagebox("Found") >strPath = .filefinder.files.item(1).path >else >messagebox("Not Found") >endif >endwith >>
******************************************************************** * 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