>******************************************************************** >* Description.......: FindFileInNetwork >* Calling Samples...: FindFileInNetwork("pdfmon.dll","c:\") >* Parameter List....: pcFileToSearch,pcSearchPath >* Created by........: Houston Brennan 06/13/2000 >* Modified by.......: Nadya Nosonovsky 06/16/2000 11:30:52 AM >******************************************************************** >lparameters pcFileToSearch,pcSearchPath >#DEFINE NoAttributesSet 0 >#DEFINE ReadOnly 1 >#DEFINE Hidden 2 >#DEFINE System 4 >#DEFINE Archived 32 > >#DEFINE DoNotSearchSubFolder 0 >#DEFINE SearchSubFolder 1 >local lni, lcRetPath >lcRetPath='' > >if type(pcFileToSearch)'C' or empty(pcFileToSearch) > return .f. >endif > >if type(pcSearchPath)'C' or empty(pcSearchPath) > pcSearchPath='c:\' && Local drive >endif > >oFiler = CREATEOBJECT( "Filer.FileUtil" ) >oFiler.SearchPath = pcSearchPath >oFiler.FileExpression = pcFileToSearch >oFiler.SubFolder = SearchSubFolder >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 >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. > > >>
>>>*- File Ref: Test_Find_Pdf.Prg && Tested under NT4 WorkStation. >>>CD C:\ >>>RUN /N2 cmd /c dir pdfmon.dll /s > c:\temp\results.txt >>>CLEAR >>>IF NOT FILE( "c:\temp\results.txt" ) >>> ? "Unable to search local disk for Acrobat Writer." >>> RETURN .F. >>>ENDIF >>> >>>cResults = FILETOSTR( "c:\temp\results.txt" ) >>>IF LEN( cResults ) > 100 AND "PDFMON.DLL" $ UPPER( cResults ) >>> ? "PDFMON.DLL is present." >>> iPositionOfpath = ATC( "Directory of ", cResults ) ; >>> + LEN( "Directory of " ) >>> cPath = SUBSTR( cResults, iPositionOfpath ) >>> iCharsToExtract = AT( CHR(13), cPath ) >>> cPath = LEFT( cPath, iCharsToExtract ) >>> ? "Path = " + cPath >>>ELSE >>> ? "PDFMON.DLL is NOT present." >>>ENDIF >>>RETURN .T. >>>>>>