c# sftp 库 Chilkat

来源:互联网 发布:网络大电影发行 编辑:程序博客网 时间:2024/06/06 12:46

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 -efcurl "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.zipcd chilkatMono-9.5.0sn -k chilkat.snkmcs -keyfile:chilkat.snk -target:library -out:chilkatMono.dll chilkatCs/*.cscp nativeDll/linux/x64/libchilkatMono-9_5_0.so .mcs -lib:. -r:chilkatMono.dll chilkatTest.csmono chilkatTest.execd ..

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 -efcurl "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.zipcd chilkatMono-9.5.0sn -k chilkat.snkmcs -keyfile:chilkat.snk -target:library -out:chilkatMono.dll chilkatCs/*.cscp nativeDll/mac/libchilkatMono-9_5_0.dylib .mcs -lib:. -r:chilkatMono.dll chilkatTest.csmono chilkatTest.execd ..


使用方法:

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.");//  Disconnectssh.Disconnect();

0 0