R
Richard Lewis Haggard
Is there an easy way to construct a list of the names of all files whose
extension is, for example, .htm in a directory? I've managed to do by
searching through all files in the folder and detecting when 'htm' was the
extension, but I did so in a rather clumsy manner. Is there a more concise
way to accomplish the same thing?.
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim strPath As String
strPath = "C:\Documents and Settings\rhaggard\Application
Data\Microsoft\Signatures"
Dim folder
Set folder = fso.GetFolder(strPath)
Dim fileCollection
Set fileCollection = folder.Files
Dim file
Dim ext As String
Dim name As String
Dim arFiles() As String
Dim iItems As Integer
iItems = 0
For Each file In fileCollection
name = file.name
Rem Is this a ".htm" file?
If Right(name, 4) = ".htm" Then
name = Left(name, Len(name) - 4)
iItems = iItems + 1
ReDim Preserve arFiles(iItems)
arFiles(iItems) = name
End If
Next
extension is, for example, .htm in a directory? I've managed to do by
searching through all files in the folder and detecting when 'htm' was the
extension, but I did so in a rather clumsy manner. Is there a more concise
way to accomplish the same thing?.
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim strPath As String
strPath = "C:\Documents and Settings\rhaggard\Application
Data\Microsoft\Signatures"
Dim folder
Set folder = fso.GetFolder(strPath)
Dim fileCollection
Set fileCollection = folder.Files
Dim file
Dim ext As String
Dim name As String
Dim arFiles() As String
Dim iItems As Integer
iItems = 0
For Each file In fileCollection
name = file.name
Rem Is this a ".htm" file?
If Right(name, 4) = ".htm" Then
name = Left(name, Len(name) - 4)
iItems = iItems + 1
ReDim Preserve arFiles(iItems)
arFiles(iItems) = name
End If
Next