Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SFtp;
...
procedure TForm 一.Button 一Click(Sender: TObject);
var
sftp: HCkSFtp;
hostname: PWideChar;
port: Integer;
success: Boolean;
remoteFilePath: PWideChar;
localFilePath: PWideChar;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
sftp := CkSFtp_Create();
// Set some timeouts, in milliseconds:
CkSFtp_putConnectTimeoutMs(sftp, 五000);
CkSFtp_putIdleTimeoutMs(sftp, 一0000);
// Connect to the SSH server.
// The standard SSH port = 二 二
// The hostname may be a hostname or IP address.
hostname := 三 九;sftp.example.com 三 九;;// ip
port := 二 二;// 端心
success := CkSFtp_Connect(sftp,hostname,port);
if (success <> True) then
begin
Memo 一.Lines.Add(CkSFtp__lastErrorText(sftp));
Exit;
end;
// Authenticate with the SSH server. Chilkat SFTP supports
// both password-based authenication as well as public-key
// authentication. This example uses password authenication.
success := CkSFtp_AuthenticatePw(sftp, 三 九;myLogin 三 九;, 三 九;myPassword 三 九;);// 账号暗码
if (success <> True) then
begin
Memo 一.Lines.Add(CkSFtp__lastErrorText(sftp));
Exit;
end;
// After authenticating, the SFTP subsystem must be initialized:
success := CkSFtp_InitializeSftp(sftp);
if (success <> True) then
begin
Memo 一.Lines.Add(CkSFtp__lastErrorText(sftp));
Exit;
end;
// Download the file:
localFilePath := 三 九;c:/temp/hamlet.xml 三 九;;// 当地 保留 路径
remoteFilePath := 三 九;subdir 一/subdir 二/hamlet.xml 三 九;; //效劳 器文献路径
// The ResumeDownloadFileByName method will check
// the local file and begin downloading the remote file
// at the appropriate point. For example, if the local
// file is already 二 一 五 六 二 四 bytes long, it will begin downloading
// the remote file at the 二 一 五 六 二 五 三 九;th byte -- appending to
// the local file.
success := CkSFtp_ResumeDownloadFileByName(sftp,remoteFilePath,localFilePath);
if (success <> True) then
o
n
c