title: SFTP Upload using sshnet library - Handling Connection Issues
body: <p>Using Renci's sshnet library, I am unable to handle connection issues while uploading a file.</p>
  
  <p>If I set a break point on UploadFile, disable my connection, and let it run, it just hangs on that line. These are potentially big files on slow connections, so adding an OperationTimeout would be difficult.</p>
  
  <p>Also, this works fine over and over on consistent connections. Any ideas? Thanks!</p>
  
  <pre><code>AuthenticationMethod[] methods = new AuthenticationMethod[1];
  methods[0] = new PasswordAuthenticationMethod(username, pwd);
  
  var con = new ConnectionInfo(Config.RemoteHostName, username, methods);
  con.Timeout = new TimeSpan(0, 0, 0, 30);
  var client = new SftpClient(con);
  
  client.Connect();
  
  string fullFilePath = string.Format("{0}{1}", Config.RemoteFilePath, filename);
  client.BufferSize = 15000;
  client.UploadFile(new MemoryStream(buffer), fullFilePath);
  client.Disconnect();
  </code></pre>