我有一个 FTP 服务器,我想从中下载本地目录中不存在的所有文件。
我试着做一个For Next
,但我就是无法理解它。我尝试枚举文件,但由于对两个列表都这样做,我得到了一个错误。我认为该错误可能是由于使用本地列表中的单个枚举文件交叉检查在线文件引起的。我该如何消除这个问题?
链接到 FTPClient 类代码:
https://docs.google.com/file/d/0BxFwEuHe1g77TEw2ckZxVUlQdGM/edit?usp=sharing
所有代码:
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