c# sftp 库 Chilkat

http://www.chilkatsoft.com/mono.asp


Sample Script for Install/Testing on 64-bit Linux

Note: The download URL is for v9.5.0.54. At the time of this writing, it was the latest version of Chilkat.

#!/bin/bash -ef

curl "http://www.chilkatsoft.com/download/9.5.0.54/chilkatMono-9.5.0.zip" -o "chilkatMono-9.5.0.zip"
unzip chilkatMono-9.5.0.zip
cd chilkatMono-9.5.0
sn -k chilkat.snk
mcs -keyfile:chilkat.snk -target:library -out:chilkatMono.dll chilkatCs/*.cs
cp nativeDll/linux/x64/libchilkatMono-9_5_0.so .
mcs -lib:. -r:chilkatMono.dll chilkatTest.cs
mono chilkatTest.exe
cd ..

Sample Script for Install/Testing on MAC OS X

Note: The download URL is for v9.5.0.54. At the time of this writing, it was the latest version of Chilkat.

#!/bin/bash -ef

curl "http://www.chilkatsoft.com/download/9.5.0.54/chilkatMono-9.5.0.zip" -o "chilkatMono-9.5.0.zip"
unzip chilkatMono-9.5.0.zip
cd chilkatMono-9.5.0
sn -k chilkat.snk
mcs -keyfile:chilkat.snk -target:library -out:chilkatMono.dll chilkatCs/*.cs
cp nativeDll/mac/libchilkatMono-9_5_0.dylib .
mcs -lib:. -r:chilkatMono.dll chilkatTest.cs
mono chilkatTest.exe
cd ..


使用方法:

http://www.example-code.com/csharp/scp_upload_file.asp

//  Important: It is helpful to send the contents of the
//  ssh.LastErrorText property when requesting support.

Chilkat.Ssh ssh = new Chilkat.Ssh();

//  Any string automatically begins a fully-functional 30-day trial.
bool success = ssh.UnlockComponent("30-day trial");
if (success != true) {
    Console.WriteLine(ssh.LastErrorText);
    return;
}

//  Connect to an SSH server:
string hostname;
int port;

//  Hostname may be an IP address or hostname:
hostname = "www.some-ssh-server.com";
port = 22;

success = ssh.Connect(hostname,port);
if (success != true) {
    Console.WriteLine(ssh.LastErrorText);
    return;
}

//  Wait a max of 5 seconds when reading responses..
ssh.IdleTimeoutMs = 5000;

//  Authenticate using login/password:
success = ssh.AuthenticatePw("myLogin","myPassword");
if (success != true) {
    Console.WriteLine(ssh.LastErrorText);
    return;
}

//  Once the SSH object is connected and authenticated, we use it
//  as the underlying transport in our SCP object.
Chilkat.Scp scp = new Chilkat.Scp();

success = scp.UseSsh(ssh);
if (success != true) {
    Console.WriteLine(scp.LastErrorText);
    return;
}

string remotePath = "test.txt";
string localPath = "/home/bob/test.txt";
success = scp.UploadFile(localPath,remotePath);
if (success != true) {
    Console.WriteLine(scp.LastErrorText);
    return;
}

Console.WriteLine("SCP upload file success.");

//  Disconnect
ssh.Disconnect();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值