Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: File upload failing - need help

$
0
0
jorgefdez205 wrote:
Where????
    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();
        }
    }
Please paste your exception. I highly doubt you really have the same problem.
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

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>