I have an FTP server from which I want to download all the files that do not exist in my local directory.
I tried doing a For Next
but I just can't get my head around it. I tried enumerating the files but as a result of doing it to both lists, I got an error. I think the error might be caused from cross checking the online files with an individual enumerated file from the local list. How do I eliminate this problem?
Link to FTPClient Class Code:
https://docs.google.com/file/d/0BxFwEuHe1g77TEw2ckZxVUlQdGM/edit?usp=sharing
All Code:
Dim ftp As New FTPclient("ftp://www.ahpg.zxq.net", "eg", "eg")
Dim dirList As FTPdirectory = ftp.ListDirectoryDetail("/")
Dim result As List(Of String) = ftp.ListDirectory("/")
For Each line As String In result
FTPLBX.Items.Add(line)
Next
Dim str As String
Dim locstr As String
Dim res_numer As IEnumerator
res_numer = result.GetEnumerator()
Dim loclist As List(Of String) = New List(Of String) _
(System.IO.Directory.EnumerateFiles("C:/Program Files/Business Elements/Recent Files"))
Dim LOC_Enum As IEnumerator
LOC_Enum = loclist.GetEnumerator
Do While LOC_Enum.MoveNext
locstr = (LOC_Enum.Current)
Loop
Do While (res_numer.MoveNext)
str = (res_numer.Current)
Loop
For Each str In loclist
If Not loclist.Contains(str) = True Then
My.Computer.Network.DownloadFile("ftp://www.ahpg.zxq.net/ftpfiles/" & str.ToString, _
"C:/Program Files/Business Elements/Recent Files/" & str.ToString, "eg", "eg")
MessageBox.Show("Done ")
End If
Next
End Sub