A Simple Directory Search Module
I tried to make this as light as possible just add it to your app and call SearchDirs. It takes two arguments the path to search in and the file or directory to find. It puts alot of Data on the Call Stack however it's very very fast. 3 API's, 5 Constants, 3 User Types, no activex or OLE runtime objects. Thanks and feel free to email if you have any questions
AI
Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Codice sorgente
'Chris King 01/08/2000 c_king@mtv.com Option Explicit Public Function SearchDirs(Curpath$, strFName$) Dim strProg$ Dim dirs% Dim dirbuf$() Dim hItem& Dim i% Dim rtn As Boolean If Curpath$ = "" Then Exit Function If strFName$ = "" Then Exit Function If Right(strFName$, 1) = VBBACKSLASH Then strFName = Left(strFName, InStr(1, strFName, VBBACKSLASH, vbTextCompare) - 1) End If If Right(Curpath$, 1) <> VBBACKSLASH Then Curpath$ = Curpath$ & VBBACKSLASH End If hItem& = FindFirstFile(Curpath$ & VBALLFILES, WFD) If hItem& <> INVALID_HANDLE_VALUE Then Do If (WFD.dwFileAttributes And vbDirectory) Then If Asc(WFD.cFileName) <> VBKEYDOT Then If (dirs% Mod 10) = 0 Then ReDim Preserve dirbuf$(dirs% + 10) dirs% = dirs% + 1 dirbuf$(dirs%) = Left$(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1) End If End If strProg$ = Left(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1) If UCase(strProg$) = UCase(strFName$) Then SearchDirs = True Exit Function Else SearchDirs = False End If DoEvents Loop While FindNextFile(hItem&, WFD) Call FindClose(hItem&) End If For i% = 1 To dirs% rtn = SearchDirs(Curpath$ & dirbuf$(i%) & VBBACKSLASH, strFName$) SearchDirs = rtn If rtn Then Exit Function Next i% End Function
Commenti originali (3)
Recuperato da Wayback Machine