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
(DataFlex) FTP Upload / Download to StringBuilderDemonstrate how to upload from a Chilkat StringBuilder object, and download into a StringBuilder object.
Use ChilkatAx-win32.pkg Procedure Test Handle hoFtp Boolean iSuccess Variant vSbA Handle hoSbA Boolean iBIncludeBOM String sRemoteFilename Variant vSbB Handle hoSbB Boolean iBCaseSensitive String sTemp1 Integer iTemp1 Boolean bTemp1 // This example assumes Chilkat Ftp2 to have been previously unlocked. // See Unlock Ftp2 for sample code. Get Create (RefClass(cComChilkatFtp2)) To hoFtp If (Not(IsComObjectCreated(hoFtp))) Begin Send CreateComObject of hoFtp End Set ComHostname Of hoFtp To "www.my-ftp-server.com" Set ComUsername Of hoFtp To "mFtpLogin" Set ComPassword Of hoFtp To "myFtpPassword" // Connect to the FTP server. Get ComConnectOnly Of hoFtp To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoFtp To sTemp1 Showln sTemp1 Procedure_Return End // Authenticate with the FTP server. Get ComLoginAfterConnectOnly Of hoFtp To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoFtp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatStringBuilder)) To hoSbA If (Not(IsComObjectCreated(hoSbA))) Begin Send CreateComObject of hoSbA End Get ComLoadFile Of hoSbA "qa_data/hamlet.xml" "utf-8" To iSuccess // Upload the contents of sbA to the FTP server. Move False To iBIncludeBOM Move "hamletFromSb.xml" To sRemoteFilename Get pvComObject of hoSbA to vSbA Get ComPutFileSb Of hoFtp vSbA "utf-8" iBIncludeBOM sRemoteFilename To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoFtp To sTemp1 Showln sTemp1 Procedure_Return End // Download... Get Create (RefClass(cComChilkatStringBuilder)) To hoSbB If (Not(IsComObjectCreated(hoSbB))) Begin Send CreateComObject of hoSbB End Get pvComObject of hoSbB to vSbB Get ComGetFileSb Of hoFtp sRemoteFilename "utf-8" vSbB To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoFtp To sTemp1 Showln sTemp1 Procedure_Return End // Verify that sbA and sbB have the exact same contents. Get ComLength Of hoSbA To iTemp1 Showln "size of sbA: " iTemp1 Move True To iBCaseSensitive Get ComContentsEqualSb Of hoSbA Get pvComObject of hoSbB to vSbB vSbB iBCaseSensitive To bTemp1 If (bTemp1 = True) Begin Showln "Contents are equal. Success." End Else Begin Showln "Contents are NOT equal. Failed." End Get ComDisconnect Of hoFtp To iSuccess End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.