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

New Post: File upload failing - need help

$
0
0
I am currently trying to upload a file via sFTP:
        public bool UploadFile(Settings settings, string localPath)
        {
            try
            {
                using (var sftp = new SftpClient(settings.Host, settings.Username, settings.Password))
                {
                    sftp.Connect();
                    using (var fileStream = File.OpenRead(localPath))
                    {
                        sftp.UploadFile(fileStream, settings.RemoteDirectory, true);
                    }
                    sftp.Disconnect();
                }
                return true;
            }
            catch (Exception ex)
            {
                Utility.Err(ex, "UploadFile()");
                return false;
            }
        }
The error message I am getting is:
Renci.SshNet.Common.SshException was caught
  HResult=-2146233088
  Message=Failure
  Source=Renci.SshNet
  StackTrace:
       at Renci.SshNet.Sftp.SftpSession.RequestOpen(String path, Flags flags, Boolean nullOnError)
       at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, Flags flags, SftpUploadAsyncResult asyncResult, Action`1 uploadCallback)
       at Renci.SshNet.SftpClient.UploadFile(Stream input, String path, Boolean canOverride, Action`1 uploadCallback)
       at Renci.SshNet.SftpClient.UploadFile(Stream input, String path, Action`1 uploadCallback)
       at MyProj.Models.MyClass.UploadFile(Settings settings, String localPath) in c:\Users\Me\Documents\Visual Studio 2013\Projects\MyProj\MyProj\Models\MyClass.cs:line 19
  InnerException: 
There is no inner exception given

The remote directory I am trying to upload to is "./inbound/". When downloading, using "./outbound/" works fine.

Any help will be appreciated

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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