Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio 2015 & .NET 4.6
  4. Upload and Download using SFTP

Upload and Download using SFTP

Scheduled Pinned Locked Moved Visual Studio 2015 & .NET 4.6
comsysadminhelpquestion
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sjs4u
    wrote on last edited by
    #1

    Hi, I have "sftp://ftp4.abc.com" url with username and password for FTP Details. I have port no 22 and with this details I am able to connect to the server using FileZila I am using FTPWebRequest to upload and download the files from server and my code is working for my existing FTP details which is not secure. But When I use the above details it showing the error The underlying connection was closed: The connection was closed unexpectedly. Here is my code to execute the url Uri uriObj = new Uri(uri); var r = (FtpWebRequest)WebRequest.Create(uriObj); r.Credentials = new NetworkCredential(ftpUsername, ftpPassword); r.Method = method; r.UsePassive = true; r.EnableSsl=true; r.UseBinary = true; r.KeepAlive = true; return r; let me know how can i use sftp with existing code or any other solution for the same. Regards, sjs

    Richard DeemingR 1 Reply Last reply
    0
    • S sjs4u

      Hi, I have "sftp://ftp4.abc.com" url with username and password for FTP Details. I have port no 22 and with this details I am able to connect to the server using FileZila I am using FTPWebRequest to upload and download the files from server and my code is working for my existing FTP details which is not secure. But When I use the above details it showing the error The underlying connection was closed: The connection was closed unexpectedly. Here is my code to execute the url Uri uriObj = new Uri(uri); var r = (FtpWebRequest)WebRequest.Create(uriObj); r.Credentials = new NetworkCredential(ftpUsername, ftpPassword); r.Method = method; r.UsePassive = true; r.EnableSsl=true; r.UseBinary = true; r.KeepAlive = true; return r; let me know how can i use sftp with existing code or any other solution for the same. Regards, sjs

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      The built-in FTP request doesn't support SFTP. You'll need to use a third-party library - for example, http://sshnet.codeplex.com/[^].


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups