'Funtion to get list of the specific type of files(Based on extension) in specified folder. In this example will filter 'out file having "txt", "qfl" & "vbs" extension. To get the list of file you have keept Array global for atleast that 'file (depend on implementation).
Public Function GetFileList (folderLocation, RequiredfileNames()) 'As Boolean
'Initialize the function and declare the variables
GetFileList = False
Dim fso, sfileName, files, fileCount, folder, selectedFile
fileCount = 0
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(folderLocation)
Set files = folder.Files
'Browse through all the files in the selected folder
For each selectedFile In files
sfileName = selectedFile.Name
'Filter the file based on the extension of the file
If (StrComp(Right(sfileName,3), "txt", 1) Or StrComp(Right(sfileName,3), "qfl", 1) Or StrComp(Right(sfileName,3), "vbs", 1)) Then
ReDim Preserve RequiredfileNames(fileCount)
RequiredfileNames(fileCount) = sfileName
fileCount = fileCount + 1
End If
Next
'Finalize the function and return the value
If(fileCount > 0) Then
GetFileList = True
End If
End Function
Public Function GetFileList (folderLocation, RequiredfileNames()) 'As Boolean
'Initialize the function and declare the variables
GetFileList = False
Dim fso, sfileName, files, fileCount, folder, selectedFile
fileCount = 0
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(folderLocation)
Set files = folder.Files
'Browse through all the files in the selected folder
For each selectedFile In files
sfileName = selectedFile.Name
'Filter the file based on the extension of the file
If (StrComp(Right(sfileName,3), "txt", 1) Or StrComp(Right(sfileName,3), "qfl", 1) Or StrComp(Right(sfileName,3), "vbs", 1)) Then
ReDim Preserve RequiredfileNames(fileCount)
RequiredfileNames(fileCount) = sfileName
fileCount = fileCount + 1
End If
Next
'Finalize the function and return the value
If(fileCount > 0) Then
GetFileList = True
End If
End Function
Thiѕ is rеally іntеresting, You are a very sκilled blogger.
ReplyDeleteI havе joined your feеd and look forwaгd to sееking mοге of youг magnificеnt poѕt.
Alѕo, I've shared your web site in my social networks!
My website Buy Proxylist