![]() |
Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • Node.js • Objective-C • PHP Extension • Perl • PowerBuilder • PowerShell • PureBasic • Ruby • SQL Server • Swift • Tcl • Unicode C • Unicode C++ • VB.NET • VBScript • Visual Basic 6.0 • Visual FoxPro • Xojo Plugin
(Lianja) Get FTP File PermissionsLianja example showing how to retrieve file permissions (via FTP) for each file in a remote directory.
// This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loFtp = createobject("CkFtp2") // Set the various properties to establish the connection. loFtp.Hostname = "ftp.example.com" loFtp.Username = "login" loFtp.Password = "password" // If SSL/TLS is required.. // See http://www.cknotes.com/determining-ftp2-connection-settings/ // for more information. loFtp.AuthTls = .T. loFtp.PassiveUseHostAddr = .T. // Connect to the FTP server: llSuccess = loFtp.ConnectOnly() if (llSuccess <> .T.) then ? loFtp.LastErrorText release loFtp return endif // Authenticate with the FTP server. llSuccess = loFtp.LoginAfterConnectOnly() if (llSuccess <> .T.) then ? loFtp.LastErrorText release loFtp return endif // To get file permissions in UNIX format, disallow MSLD: loFtp.AllowMlsd = .F. // To get file and sub-directory information, simply // loop from 0 to ftp.GetDirCount() - 1 i = 0 n = loFtp.GetDirCount() if (n < 0) then ? loFtp.LastErrorText release loFtp return endif // Show the type of permissions information that is available. // The two most common types are "mlsd" and "unix". See the // online reference documentation for more information. if (n > 0) then ? "The permissions format is: " + loFtp.GetPermType(0) endif do while i < n // Display the permissions and filename ? loFtp.GetPermissions(i) + " " + loFtp.GetFilename(i) i = i + 1 enddo // Assuming MLSD was possible, let's see the file permissions in MLSD format: loFtp.AllowMlsd = .T. // Clear the directory cache so we're forced to re-fetch the directory listing: loFtp.ClearDirCache() n = loFtp.GetDirCount() if (n < 0) then ? loFtp.LastErrorText release loFtp return endif // Show the type of permissions information that is available. // The two most common types are "mlsd" and "unix". See the // online reference documentation for more information. if (n > 0) then ? "----" ? "The permissions format is: " + loFtp.GetPermType(0) endif i = 0 do while i < n // Display the permissions and filename ? loFtp.GetPermissions(i) + " " + loFtp.GetFilename(i) i = i + 1 enddo llSuccess = loFtp.Disconnect() release loFtp |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.