Hei Tue
Det tar litt tid -men her er et rekursivt søk som finner Bookmark.htm på
C:\.
'*******************
Option Explicit
Dim blnFoundit As Boolean
Private Sub Btn1_Click()
blnFoundit = False
Call GetFilesInDirectory("C:\", "*.htm")
Call LookForDirectories("C:\", "*.htm")
End Sub
Sub LookForDirectories(ByVal DirToSearch As String, _
strSuffix As String)
Dim counter As Integer
Dim i As Integer
Dim Directories() As String
Dim Contents As String
counter = 0
If Right(DirToSearch, 1) <> "\" Then DirToSearch = DirToSearch & "\"
Contents = Dir(DirToSearch, vbDirectory)
Do While Contents <> ""
If Contents <> "." And Contents <> ".." Then
If (GetAttr(DirToSearch & Contents) And _
vbDirectory) = vbDirectory Then
counter% = counter% + 1
ReDim Preserve Directories(counter)
Directories(counter) = DirToSearch & Contents
End If
End If
Contents = Dir
Loop
If counter = 0 Then Exit Sub
For i = 1 To counter
Call GetFilesInDirectory(Directories(i), strSuffix)
If blnFoundit = True Then Exit Sub
Call LookForDirectories(Directories(i), strSuffix)
Next i
End Sub
Sub GetFilesInDirectory(ByVal DirToSearch As String, _
strSuffix As String)
Dim NextFile As String
'Dim itmX As ListItem
On Error Resume Next
NextFile = Dir(DirToSearch & "\" & strSuffix)
Do Until NextFile = ""
If NextFile = "Bookmark.htm" Then
blnFoundit = True
MsgBox "Found it at " & DirToSearch
Exit Sub
End If
NextFile = Dir()
Loop
End Sub
HTH. Beste hilsen Harald
"Tue Hellstern" <info@f1-support.dk> skrev i melding
news:3cf11426$0$70509$edfadb0f@dspool01.news.tele.dk...
> Hej NG,
>
> Jeg har et "lille" problem
>
> Hvordan "leder" man efter en fil på hele harddisken, jeg har bruge for at
> vide om en bestemt file er på brugerens maskine. Hvis den er der skal jeg
> bruge stien ned til den.
>
> Det er i VB 6.0 jeg skal bruge denne oplysning.
>
> Jeg har prøvet at lede i hjælpen men jeg kan ikke finde noget.
>
>
>
> Tue
>
>
>