Szybkie szukanie
Słowo kluczowe:
sobota, 11 luty 2012
Start arrow Tips & Tricks arrow Wyszukiwanie plików
Wyszukiwanie plików Drukuj E-mail
Napisał Administrator   
sobota, 21 styczeń 2006
'sprawdza czy plik istnieje, gdy tak pokazuje jego lokacje
'btw: znajduje tylko pierwszy
'Zmien tylko kod aby znalezc wszystkie
'uzyj

'MsgBox FindFile("c:\", vFile$) & vFile$

Public Function FileExist(Path$) As Integer
Dim x

x = FreeFile

On Error Resume Next
Open Path$ For Input As x
If Err = 0 Then
FileExist = True
Else
FileExist = False
End If
Close x

End Function

Public Function FindFile(ByVal Path As String, ByVal File As String) As String
Dim DirName As String, LastDir As String

If File = "" Then Exit Function
If Right(Path, 1) <> "\" Then Path = Path & "\"

DirName = Dir(Path & "*.*", vbDirectory)
Do While Not FileExist(Path & File)

If DirName = "" Then Exit Do
DoEvents
If DirName <> "." And DirName <> ".." Then
If (GetAttr(Path & DirName) And vbDirectory) = vbDirectory Then
LastDir = DirName
DirName = FindFile(Path & DirName & "\", File)
If DirName <> "" Then
Path = DirName
Exit Do
End If
DirName = Dir(Path, vbDirectory)
Do Until DirName = LastDir Or DirName = ""
DirName = Dir
Loop
If DirName = "" Then Exit Do
End If
End If
DirName = Dir
Loop

If FileExist(Path & File) Then FindFile = Path

End Function

Komentarze

Aby dodać komentarz zaloguj się. Jeśli nie masz konta, załóż je sobie.
Tylko zarejestrowani użytkownicy mogą pisać komentarze.

Powered by AkoComment 2.0!

< Poprzedni   Następny >

Menu główne
Start
Teoria
VB.NET
Api
Tips & Tricks
Warsztat
VBMagazine
Pliki
Forum
Literatura
Ankiety
Linki
Szukaj
Wyślij program
Napisz do nas
Redakcja
Logowanie
Login

Hasło

Zapamiętaj mnie
Nie pamiętasz hasła?
Nie masz konta? Załóż je sobie
Gościmy
Aktualnie jest 58 gości online
Statystyka
Użytkownicy: 11345
Newsy: 237
Odnośniki: 48
Odwiedzających: 4327626
Mambo is Free Software released under the GNU/GPL License.