title: C# Multiple Download from FTP using parallel task - Duplicate Download issue
body: <p>I am facing a strange issue, I want to download a list of files from FTP. I preferred to go with Parallel Task. Below is my code. The issue is, all the list of files are getting downloaded, but duplicate files with different name are being generated. I am very new to Parallel task concept. Please help me to find out the issue. </p>
  
  <p><strong>Note</strong>: I am using SSH.Net for sftp connection and download.</p>
  
  <pre><code>    private void ConcurrentDownload()
      {
          // Declaring Connection Information
          PasswordAuthenticationMethod pm = new PasswordAuthenticationMethod("FTPUserName", "Password");
          ConnectionInfo connectionInfo = new ConnectionInfo("FTPHost", 22, "FTPUserName", ProxyTypes.Socks5, "127.0.0.1", 8080, string.Empty, string.Empty, pm);
  
          using (SftpClient sfc = new SftpClient(connectionInfo))
          {
          // Establish the remote connection
          sfc.Connect();
  
          // Getting Remote Directory Contents
          IEnumerable&lt;SftpFile&gt; sFiles = new List&lt;SftpFile&gt;();    
          sFiles = sfc.ListDirectory(".\\");
  
          // Building the File List                
          List&lt;string&gt; remotefiles = new List&lt;string&gt;();
          foreach (SftpFile sfile in sFiles)
          {
           if (!sfile.IsDirectory)
           {
             string ss = sfile.Name;
             remotefiles.Add(ss);
           }
          }
  
          // Parallel Download
          Parallel.ForEach(remotefiles.Distinct(), file =&gt; DownloadFile(sfc, file)); 
          sfc.Disconnect();
          }
      }
  
     private void DownloadFile(SftpClient sf, string RemoteFileName)
     {
          using (Stream ms = File.OpenWrite(RemoteFileName))
          {
              sf.DownloadFile(RemoteFileName, ms);
          }
     }
  </code></pre>