Подскажите кто-нибудь как сделать поиск файла по имени, плиззз.
Заранее спасибо!
- Код: Выделить всё
Private Sub ScanFolder(CurrentPath As String)
Dim nI As Integer, nDirectory As Integer
Dim sFileName As String, sDirectoryList() As String
Dim Ext As String
Dim strDescription As String
Dim strURL As String
Dim NewListItem As MSComctlLib.ListItem
Me.Caption = "Поиск в папке: " & CurrentPath
sFileName = Dir(CurrentPath)
Do While sFileName <> ""
Ext = LCase$(Mid$(sFileName, InStrRev(sFileName, ".") + 1))
If Ext = "url" Then
strDescription = Mid$(sFileName, 1, Len(sFileName) - Len(Ext) - 1)
strURL = sFileName
Set NewListItem = lvwURL.ListItems.Add(, , strURL, , 1)
NewListItem.SubItems(1) = strDescription
NewListItem.SubItems(2) = Mid$(CurrentPath, 1, Len(CurrentPath) - 1)
End If
sFileName = Dir
DoEvents
Loop
sFileName = Dir(CurrentPath, vbDirectory)
Do While sFileName <> ""
If sFileName <> "." And sFileName <> ".." And sFileName <> "?" Then
If GetAttr(CurrentPath & sFileName) And vbDirectory Then
nDirectory = nDirectory + 1
ReDim Preserve sDirectoryList(nDirectory)
sDirectoryList(nDirectory) = CurrentPath & sFileName
End If
End If
sFileName = Dir
DoEvents
Loop
For nI = 1 To nDirectory
ScanFolder sDirectoryList(nI) & ""
DoEvents
Next nI
Me.Caption = "Поиск завершен"End Sub
вставь этот кусок в модуль формы. на форме размести ListView с именем lvwURL. вобщем эта процедура ищет все файлы с расширением url и добавляет их в ListView
Ext = LCase$(Mid$(sFileName, InStrRev(sFileName, ".") + 1))
If Ext = "url" Then
...
Сейчас этот форум просматривают: Yandex-бот и гости: 21