相关疑难解决方法(0)

Downloading a directory using SSH.NET SFTP in C#

I am using Renci.SSH and C# to connect to my Unix server from a Windows machine. My code works as expected when the directory contents are only files, but if the directory contains a folder, I get this

Renci.SshNet.Common.SshException: 'Failure'

这是我的代码,我如何更新它以下载目录(如果存在)

private static void DownloadFile(string arc, string username, string password)
{
    string fullpath;
    string fp;
    var options = new ProgressBarOptions
    {
        ProgressCharacter = '.',
        ProgressBarOnBottom = true
    };

    using (var sftp = new SftpClient(Host, username, password))
    {
        sftp.Connect();
        fp = …
Run Code Online (Sandbox Code Playgroud)

.net c# sftp ssh.net

7
推荐指数
1
解决办法
2万
查看次数

使用SSH.NET显示ProgressBar中文件上载的进度

我想在我的上传过程中显示上传过程的进度ProgressBar,这是我的按钮"上传"的代码:

private void button2_Click(object sender, EventArgs e)
{
    int Port = int.Parse(textBox2.Text);
    string Host = textBox1.Text;
    string Username = textBox3.Text;
    string Password = textBox4.Text;
    string WorkingDirectory = textBox6.Text;
    string UploadDirectory = textBox5.Text;

    FileInfo FI = new FileInfo(UploadDirectory);
    string UploadFile = FI.FullName;
    Console.WriteLine(FI.Name);
    Console.WriteLine("UploadFile" + UploadFile);

    var Client = new SftpClient(Host, Port, Username, Password);
    Client.Connect();
    if (Client.IsConnected)
    {
        var FS = new FileStream(UploadFile, FileMode.Open);
        if (FS != null)
        {
            Client.UploadFile(FS, WorkingDirectory + FI.Name, null);
            Client.Disconnect();
            Client.Dispose();
            MessageBox.Show(
                "Upload complete", …
Run Code Online (Sandbox Code Playgroud)

.net c# sftp winforms ssh.net

3
推荐指数
1
解决办法
4713
查看次数

标签 统计

.net ×2

c# ×2

sftp ×2

ssh.net ×2

winforms ×1