Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find a filename
Message
De
16/06/2000 12:00:36
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00379476
Message ID:
00381455
Vues:
24
>>I was thinking of RUN as a possibility too, but I hate using the RUN command. *s* One thing, though, Nadya said the file could be anywhere on the network, and the code below will only search on C:. You need to add a loop through all the drive letter, skipping drivetypes 1,2,5 and 6.
>
>Hi Barbara,
>
>Now sure, how to perform a loop through all network drives, if I want to search through the network. Could you please provide a code snippet? Thanks in advance.

For x = 99 to 122 && ascii for c - z
if drivetype(x) = 3 or drivetype(x) = 4
*this is a hard disk or a network drive
endif
endfor

HTH

Jon

>This is for this program:
>
>********************************************************************
>*  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.
>
>
>
>
>
>
>
>>
>>>
>>>Here is a very fast find - much quicker than using ADIR() recursively, etc. The only downside is the 'ugly' (VFP no longer in control) command shell !!
>>>
>>>
>>>*- 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.
>>>
>>>
>>>Hope this helps.
>>>Houston.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform