Upload and Download using SFTP
-
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
-
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
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