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

New Post: No such File or Directory

$
0
0
My file upload issue was finally resolved by adding the modified Upload method (redled, Feb 7, 2012) to the ScpClient.cs:
    public void Upload_2(FileInfo fileInfo, string filePath)
    {
        using (var input = new PipeStream())
        using (var channel = this.Session.CreateChannel<ChannelSession>())
        {
            channel.DataReceived += delegate(object sender, Common.ChannelDataEventArgs e)
            {
                input.Write(e.Data, 0, e.Data.Length);
                input.Flush();
            };

            channel.Open();

            //  Send channel command request
            string directoryPath = filePath.Substring(0, filePath.LastIndexOf('/') + 1);
            string filename = filePath.Substring(filePath.LastIndexOf('/') + 1);

            if (String.IsNullOrEmpty(directoryPath))
                channel.SendExecRequest(string.Format("scp -qt {0}", filename));
            else
                channel.SendExecRequest(string.Format("cd {0};", directoryPath) + string.Format("scp -qt {0}", filename));
            this.CheckReturnCode(input);

            this.InternalUpload(channel, input, fileInfo, filename);

            channel.Close();
        }
    }

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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