jorgefdez205 wrote:
Both just return "T.CSV". So your file should be uploaded to "/home/test/T.CSV".
Examples how to use UploadFile, can be found in the tests:
https://sshnet.codeplex.com/SourceControl/latest#Renci.SshClient/Renci.SshNet.Tests/Classes/SftpClientTest.Upload.cs
Where????Please paste your exception. I highly doubt you really have the same problem.static void Main(string[] args) { string host = "*.*.*.*"; string username = "test"; string password = "********"; string localFileName = "C://TEST.CSV"; string remoteFileName = System.IO.Path.GetFileName("t.CSV"); Console.ReadLine(); SshClient sshClient = new SshClient(host, 22, username, password); sshClient.Connect(); using (var sftp = new SftpClient(sshClient.ConnectionInfo)) { sftp.Connect(); using (var file = File.OpenRead(localFileName)) { sftp.UploadFile(file, remoteFileName); } sftp.Disconnect(); } }
string remoteFileName = System.IO.Path.GetFileName("sftp://testdev@10.2.11.5/testdev/Conversion/T.CSV");
string remoteFileName = System.IO.Path.GetFileName("t.CSV");
Why do you want to use Path.GetFileName?Both just return "T.CSV". So your file should be uploaded to "/home/test/T.CSV".
Examples how to use UploadFile, can be found in the tests:
https://sshnet.codeplex.com/SourceControl/latest#Renci.SshClient/Renci.SshNet.Tests/Classes/SftpClientTest.Upload.cs