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
(PureBasic) FTP Iterate over Files in Directory Matching ListPatternSee more RSA ExamplesUses the ListPattern property to iterate over the files in a directory matching the pattern.
IncludeFile "CkFtp2.pb" IncludeFile "CkStringBuilder.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. ftp.i = CkFtp2::ckCreate() If ftp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkFtp2::setCkHostname(ftp, "ftp.example.com") CkFtp2::setCkUsername(ftp, "my_login") CkFtp2::setCkPassword(ftp, "my_password") CkFtp2::setCkPort(ftp, 21) CkFtp2::setCkAuthTls(ftp, 1) success.i = CkFtp2::ckConnect(ftp) If success <> 1 Debug CkFtp2::ckLastErrorText(ftp) CkFtp2::ckDispose(ftp) ProcedureReturn EndIf ; Change to the "images" sub-directory located under our FTP account's home directory. success = CkFtp2::ckChangeRemoteDir(ftp,"images") If success <> 1 Debug CkFtp2::ckLastErrorText(ftp) CkFtp2::ckDispose(ftp) ProcedureReturn EndIf CkFtp2::setCkListPattern(ftp, "*.png") ; Fetch the current remote directory contents by calling GetDirCount n.i = CkFtp2::ckGetDirCount(ftp) If n < 0 Debug CkFtp2::ckLastErrorText(ftp) CkFtp2::ckDispose(ftp) ProcedureReturn EndIf i.i = 0 filename.s sbLocalPath.i = CkStringBuilder::ckCreate() If sbLocalPath.i = 0 Debug "Failed to create object." ProcedureReturn EndIf While i < n filename = CkFtp2::ckGetFilename(ftp,i) Debug filename ; Download this file. CkStringBuilder::ckSetString(sbLocalPath,"qa_output/") CkStringBuilder::ckAppend(sbLocalPath,filename) success = CkFtp2::ckGetFile(ftp,filename,CkStringBuilder::ckGetAsString(sbLocalPath)) If success <> 1 Debug CkFtp2::ckLastErrorText(ftp) CkFtp2::ckDispose(ftp) CkStringBuilder::ckDispose(sbLocalPath) ProcedureReturn EndIf i = i + 1 Wend CkFtp2::ckDispose(ftp) CkStringBuilder::ckDispose(sbLocalPath) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.