c# sftp 库 Chilkat
2016-04-23 16:15
941 查看
http://www.chilkatsoft.com/mono.asp
使用方法:
http://www.example-code.com/csharp/scp_upload_file.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();
相关文章推荐
- C# 中英文与Unicode之间的相互装换
- 【C#】System.IO.Stream 中flush的用法
- C#正则表达式
- C# 中的委托和事件
- C# DES (ECB模式) 加密解密 --单倍长
- z铭 WPF bitmap转bitmapimage 使用 CreateBitmapSourceFromHBitmap内存泄漏
- C# 如何获取出错的错误所在行数信息[原创]_C#教程_脚本之家
- C# 中堆与栈的浅记
- 新闻发布系统——静态方法使用问题(Static)
- C# Hello World WinForm
- 第四章:流程控制
- C# Hello World
- C#二叉树简易实例
- C# ASCII码排序
- C#中Directory.GetFiles() 函数的使用
- 进程(应用程序)之一
- C#OOP之二 变量和表达式
- C#OOP之二 变量和表达式
- C#OOP之二 变量和表达式
- C#_会员管理系统:开发三(修改密码)