title: SSH.NET Upload whole folder
body: <p>I use SSH.NET in C# 2015.</p>
  
  <p>With this method I can upload a file to my SFTP server.</p>
  
  <pre><code>public void upload()
  {
      const int port = 22;
      const string host = "*****";
      const string username = "*****";
      const string password = "*****";
      const string workingdirectory = "*****";
      string uploadfolder = @"C:\test\file.txt";
  
      Console.WriteLine("Creating client and connecting");
      using (var client = new SftpClient(host, port, username, password))
      {
          client.Connect();
          Console.WriteLine("Connected to {0}", host);
  
          client.ChangeDirectory(workingdirectory);
          Console.WriteLine("Changed directory to {0}", workingdirectory);
  
          using (var fileStream = new FileStream(uploadfolder, FileMode.Open))
          {
              Console.WriteLine("Uploading {0} ({1:N0} bytes)",
                                  uploadfolder, fileStream.Length);
              client.BufferSize = 4 * 1024; // bypass Payload error large files
              client.UploadFile(fileStream, Path.GetFileName(uploadfolder));
          }
      }
  }
  </code></pre>
  
  <p>Which works perfectly for a single file. Now I want to upload a whole folder/directory.</p>
  
  <p>Does anybody now how to achieve this?</p>