I need to know a way to connect to a FTP site through SFTP. I am using SharpSSH
and i am unable to find an example to do the program.
For now, i have downloaded the SharpSSH
.DLL
files and added as references. Now i need to write the code where i could connect, and upload/download files from the FTP server.
How can i do this ? Help.
UPDATE
Code :
//ip of the local machine and the username and password along with the file to be uploaded via SFTP.
FileUploadUsingSftp("http://Some-sftp-site.com", "username", "password", @"D:\", @"name.txt");
The above code is in the Main Method.
Then ;
private static void FileUploadUsingSftp(string FtpAddress, string FtpUserName, string FtpPassword, string FilePath, string FileName)
{
Sftp sftp = null;
try
{
// Create instance for Sftp to upload given files using given credentials
sftp = new Sftp(FtpAddress, FtpUserName, FtpPassword);
// Connect Sftp
sftp.Connect();
// Upload a file
sftp.Put(FilePath + FileName);
// Close the Sftp connection
sftp.Close();
}
finally
{
if (sftp != null)
{
sftp.Close();
}
}
}
What have you done as of right now?
We can't just give you a straight answer on 'how to upload files'....
Here is a tutorial: http://saravanandorai.blogspot.com/2012/01/sftp-and-file-upload-in-sftp-using-c.html