Archived Forum Post

Index of archived forum posts


How to Exclude Files with MGetFiles?

Nov 14 '12 at 12:33

I have been using the MGetFiles method and it works great. My question is, I want all the files except .html, .php and .gif files that might be in the directory. I know I can list out all the file types I want, like this:

Dim numFilesDownloaded As Integer

numFilesDownloaded = ftp.MGetFiles(".txt", "c:/temp") numFilesDownloaded = ftp.MGetFiles(".xxx", "c:/temp") numFilesDownloaded = ftp.MGetFiles("*.crl", "c:/temp")

If (numFilesDownloaded < 0) Then MsgBox(ftp.LastErrorText) Exit Sub End If

Is there a way to use the method to exclude certain files (in my case the html, php & gif's)?


(I'm assuming this is VB6.)

Two alternatives immediately come to mind.

1) Use the BeginDownloadFile event callback (see ) Your app can examine the filename about to be downloaded, and then set the "skip" argument to 1 to prevent it from being downloaded.

2) Write a loop that iterates over the files in the directory (as shown here: ) and then call GetFile for each file you wish to download. The performance would be the same as for calling MGetFiles.