******************************************************************** * Description.......: FindFileInNetwork * Calling Samples...: FindFileInNetwork("pdfmon.dll","c:\") * Parameter List....: pcFileToSearch,pcSearchPath, plEntireNetwork * 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 pcFileToSearch,pcSearchPath, plEntireNetwork ** Check passed parameters if vartype(pcFileToSearch)<>'C' or empty(pcFileToSearch) return .f. endif #define NoAttributesSet 0 #define readonly 1 #define hidden 2 #define system 4 #define Archived 32 #define DoNotSearchSubFolder 0 #define SearchSubFolder 1 local i, lcRetPath, lcDrive, lcSearchPath, StartTime,; prevonesc, prevescape, msgtail lcRetPath='' * note clock reading for generating final timing statistics StartTime = seconds() && # seconds since midnight * support user Escapes for interrupting the loop prevonesc = on('escape') && save previous Escape handler prevescape = 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 '+pcFileToSearch+iif(plEntireNetwork,' in the whole network...',' ...') oFiler = createobject( "Filer.FileUtil" ) oFiler.FileExpression = pcFileToSearch oFiler.SubFolder = SearchSubFolder && Search all tree if vartype(pcSearchPath)<>'C' or (empty(pcSearchPath) and !plEntireNetwork) lcSearchPath='c:\' && Local drive else lcSearchPath=pcSearchPath endif if !plEntireNetwork && Only specified path to search oFiler = createobject( "Filer.FileUtil" ) oFiler.SearchPath = lcSearchPath set message to 'Searching in '+lcSearchPath+msgtail oFiler.find(0) && Perform search if oFiler.files.count>0 && At least one file was found, pick up the first lcRetPath=oFiler.files.item[1].path endif else ** Want to search in whole network for i = 67 to 90 lcDrive = chr(i) 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 oFiler.SearchPath = lcDrive+':\' oFiler.find(0) && Perform search if m.halt or lastkey()=27 && Escape was pressed exit endif if oFiler.files.count>0 && At least one file was found, pick up the first lcRetPath=oFiler.files.item[1].path exit endif endif endfor endif * Restore settings set escape &prevescape on escape &prevonesc set message to ' ' wait clear return lcRetPath && Path to the first found file *!* FOR iFile = 1 TO oFiler.Files.Count *!* ? iFile *!* ?? " " *!* ?? oFiler.Files.Item[ iFile ].Name *!* ?? " " *!* ?? oFiler.Files.Item[ iFile ].Attr *!* ?? " " *!* ?? oFiler.Files.Item[ iFile ].Path *!* NEXT iFile *!* RETURN .T.