Note that there are some explanatory texts on larger screens.

plurals
  1. PODownload file from FTP if it does not exist in a given list of local files
    text
    copied!<p>I have an FTP server from which I want to download all the files that do not exist in my local directory.</p> <p>I tried doing a <code>For Next</code> 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? </p> <p>Link to FTPClient Class Code: </p> <p><a href="https://docs.google.com/file/d/0BxFwEuHe1g77TEw2ckZxVUlQdGM/edit?usp=sharing" rel="nofollow">https://docs.google.com/file/d/0BxFwEuHe1g77TEw2ckZxVUlQdGM/edit?usp=sharing</a></p> <p>All Code:</p> <pre><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/" &amp; str.ToString, _ "C:/Program Files/Business Elements/Recent Files/" &amp; str.ToString, "eg", "eg") MessageBox.Show("Done ") End If Next End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload