Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.8k views
in .NET FTP by (120 points)
Hi,

My code below counts number of files do be downloaded and if any new files found (not marked with "dwn"), downloads those.
I'm using older version of free FTP for .NET component and I'm trying to recognize between file and subfolder.
I'm confused about something.
When I use dir method, it extracts all files and subfolders names altogether.
But later I'm using this artificial method of recognizing files with "exists" method which returns "true" for file, but "false" for subfolder.

Does it make sense and reasonable way to do it?

Also, Is there a way to use "DIR" method or some other to extract just files not subfolder names?

-------------------------------------------------------------------------------------------
Dim ftpCxn as new FTPClient
ftpCxn.RemoteHost = strRemoteHost

ftpCxn.Connect()
ftpCxn.Login(dr(4).ToString.Trim, dr(5).ToString.Trim)

Dim arrFiles() As String = ftpCxn.Dir(strFTPSubFolder)
Dim ii As Integer = 0
Dim kk As Integer = 0
Dim iFiles As Integer = 0
Dim ll As Integer
If arrFiles.Length > 0 Then
'Count New Files To Be Downloaded and The Ones Which Exist as File (not folder)
'no easy way to recognize between folder and file, see arttificial check below
For ii = 0 To arrFiles.Length - 1
If Strings.Right(arrFiles(ii), 3).Trim.ToLower <> "dwn" And _
ftpCxn.Exists(arrFiles(ii)) = True Then

iFiles = iFiles + 1
End If
Next




Thank You

1 Answer

0 votes
by (162k points)
Use DirDetails to return an array of FTPFile objects

Categories

...