clint_22
Nov 1st, 1999, 06:14 AM
I have a piece of code that looks like this:
FindHandle = FindFirstFile(DirPath & FileSpec, FindData)
If FindHandle <> 0 Then
If FindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
If Left$(FindData.cFileName, 1) <> "." And Left$(FindData.cFileName, 2) <> ".." Then
Dirs.AddItem DirPath & Trim$(FindData.cFileName) & "\", 1
End If
Else
FileCount = FileCount + 1
ReDim Preserve Dir$(FileCount)
Dir$(FileCount) = DirPath & Trim$(FindData.cFileName)
Status.Panels(1).Text = "Collecting files: " & FileCount
End If
End If
If FindHandle <> 0 Then
Do
DoEvents
FindNextHandle = FindNextFile(FindHandle, FindData)
If FindNextHandle <> 0 Then
If FindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
If Left$(FindData.cFileName, 1) <> "." And Left$(FindData.cFileName, 2) <> ".." Then
Dirs.AddItem DirPath & Trim$(FindData.cFileName) & "\", 1
End If
Else
FileCount = FileCount + 1
ReDim Preserve Dir$(FileCount)
Dir$(FileCount) = DirPath & Trim$(FindData.cFileName)
Status.Panels(1).Text = "Collecting files: " & FileCount
End If
Else
Exit Do
End If
If Cancel Then Exit Sub
Loop
End If
Call FindClose(FindHandle)
The problem is if FileSpec is anything other than "*.*" in the following line:
FindHandle = FindFirstFile(DirPath & FileSpec, FindData)
How can I narrow the search by file types using FindFirstFile???
FindHandle = FindFirstFile(DirPath & FileSpec, FindData)
If FindHandle <> 0 Then
If FindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
If Left$(FindData.cFileName, 1) <> "." And Left$(FindData.cFileName, 2) <> ".." Then
Dirs.AddItem DirPath & Trim$(FindData.cFileName) & "\", 1
End If
Else
FileCount = FileCount + 1
ReDim Preserve Dir$(FileCount)
Dir$(FileCount) = DirPath & Trim$(FindData.cFileName)
Status.Panels(1).Text = "Collecting files: " & FileCount
End If
End If
If FindHandle <> 0 Then
Do
DoEvents
FindNextHandle = FindNextFile(FindHandle, FindData)
If FindNextHandle <> 0 Then
If FindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
If Left$(FindData.cFileName, 1) <> "." And Left$(FindData.cFileName, 2) <> ".." Then
Dirs.AddItem DirPath & Trim$(FindData.cFileName) & "\", 1
End If
Else
FileCount = FileCount + 1
ReDim Preserve Dir$(FileCount)
Dir$(FileCount) = DirPath & Trim$(FindData.cFileName)
Status.Panels(1).Text = "Collecting files: " & FileCount
End If
Else
Exit Do
End If
If Cancel Then Exit Sub
Loop
End If
Call FindClose(FindHandle)
The problem is if FileSpec is anything other than "*.*" in the following line:
FindHandle = FindFirstFile(DirPath & FileSpec, FindData)
How can I narrow the search by file types using FindFirstFile???