SFTP upload with SSH.
NET
===========
const string host = "[Link]";
const string username = "chucknorris";
const string password = "norrischuck";
const string workingdirectory = "/highway/hell";
const string uploadfile = @"c:\[Link]";
[Link]("Creating client and connecting");
using (var client = new SftpClient(host, port, username, password))
{
[Link]();
[Link]("Connected to {0}", host);
[Link](workingdirectory);
[Link]("Changed directory to {0}", workingdirectory);
var listDirectory = [Link](workingdirectory);
[Link]("Listing directory:");
foreach (var fi in listDirectory)
{
[Link](" - " + [Link]);
}
using (var fileStream = new FileStream(uploadfile, [Link]))
{
[Link]("Uploading {0} ({1:N0} bytes)", uploadfile,
[Link]);
[Link] = 4 * 1024; // bypass Payload error large files
[Link](fileStream, [Link](uploadfile));
}
}
==============
Missing declare the variable "port"
====================
We are trying to upload files in D:\ drive but, this library only allows to upload
files in C:\ and its subdirectories. We have tried, ChangeDirectory() to change the
root directory to D:\ which fails with the error - "No such file".
Any thought would be appreciated, on how can we achieve it?