Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) FTP XCRCDemonstrates how to tell Chilkat FTP2 to automatically verify an upload using XCRC. XCRC is an FTP extension supported by most FTP servers. If your FTP server does not support XCRC, then no XCRC command will be sent to verify the upload. The XCRC command asks the FTP server to send an CRC checksum (hash) for the contents of a file. The client can then verify that the checksum matches the local file. The FTP2 Put* methods automatically do this when the AutoXcrc property is turned on. Note: In order for the FTP2 component to know whether XCRC is supported by your FTP server, you must have the AutoFeat property turned on (which is the default setting). The AutoFeat property tells the FTP2 component to automatically request the FTP server features via the FEAT command after connecting. Note: XCRC is new functionality that is present in the pre-release downloads at http://www.chilkatsoft.com/preRelease.asp, or in official new versions dated after 30-Oct-2007. If you have trouble, please contact support@chilkatsoft.com.
#include <C_CkFtp2W.h> void ChilkatSample(void) { HCkFtp2W ftp; BOOL success; const wchar_t *localFilename; const wchar_t *remoteFilename; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. ftp = CkFtp2W_Create(); CkFtp2W_putHostname(ftp,L"ftp.example.com"); CkFtp2W_putUsername(ftp,L"login"); CkFtp2W_putPassword(ftp,L"password"); // Turn on the AutoXcrc property: CkFtp2W_putAutoXcrc(ftp,TRUE); // Turn on session logging. We'll want to examine it to // see the XCRC command: CkFtp2W_putKeepSessionLog(ftp,TRUE); // Connect and login to the FTP server. success = CkFtp2W_Connect(ftp); if (success != TRUE) { wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp)); CkFtp2W_Dispose(ftp); return; } // Change to the remote directory where the file will be uploaded. success = CkFtp2W_ChangeRemoteDir(ftp,L"junk"); if (success != TRUE) { wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp)); CkFtp2W_Dispose(ftp); return; } // Upload a file. localFilename = L"hamlet.xml"; remoteFilename = L"hamlet.xml"; success = CkFtp2W_PutFile(ftp,localFilename,remoteFilename); if (success != TRUE) { wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp)); CkFtp2W_Dispose(ftp); return; } // If we examine the session log, we'll see the XCRC command: wprintf(L"%s\n",CkFtp2W_sessionLog(ftp)); success = CkFtp2W_Disconnect(ftp); wprintf(L"File Uploaded!\n"); // Here is the session log showing the XCRC command: // 220 Serv-U FTP Server v6.3 for WinSock ready... // . // USER example-code.com // 331 User name okay, need password. // . // PASS **** // 230 User logged in, proceed. // . // TYPE I // 200 Type set to I. // . // SYST // 215 UNIX Type: L8 // . // FEAT // 211-Extension supported // CLNT // MDTM // MDTM YYYYMMDDHHMMSS[+-TZ];filename // SIZE // SITE PSWD;EXEC;SET;INDEX;ZONE;CHMOD;MSG // REST STREAM // XCRC filename;start;end // MODE Z // MLST Type*;Size*;Create;Modify*;Win32.ea*; // 211 End // . // CWD junk // 250 Directory changed to /junk // . // PORT 192,168,1,103,5,144 // 200 PORT Command successful. // . // STOR hamlet.xml // 150 Opening BINARY mode data connection for hamlet.xml. // 226 Transfer complete. // . // XCRC hamlet.xml // 250 3C1933B CkFtp2W_Dispose(ftp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.