sharpSsh - A Secure Shell (SSH) library for .NET
www.codeproject.com/KB/IP/sharpssh.aspx
string filePath = @"C:\FtpFrom\File.txt";
string userName = "yourUserName";
string host = "YourServerName";
string password = "YourPassword";
Sftp sftpClient = new Sftp(host, userName, password);
sftpClient.Connect();
sftpClient.Put(filePath, @"Foleder1/Folder2/File.txt");
---------------------------------------------------------------------------------------------
JSch jsch=new JSch();
jsch.addIdentity(privateKeyFile);
Session session=jsch.getSession(user, remoteHost, 22);
Hashtable config=new Hashtable();
config.Add("StrictHostKeyChecking", "no");
session.setConfig(config);session.connect();
Channel channel=session.openChannel("sftp");
channel.connect();
ChannelSftp c=(ChannelSftp)channel;
c.put(sourceFile, destFile);
channel.disconnect();
----------------------------------------------------------------------------------------------
JSch jsch=new JSch();
Session session=jsch.getSession(user, remoteHost, 22);
session.setPassword( pass );
Hashtable config=new Hashtable();
config.Add("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
Channel channel=session.openChannel("sftp");
channel.connect();
ChannelSftp c=(ChannelSftp)channel;
c.put(sourceFile, destFile);
channel.disconnect();
----------------------------------------------------------------------------------------------
-- 18/01/2010 11:03:18: post edited by sergey.