13.2 FTPFileMgr Object

Features:

13.2.1 BinMode property

Sets or returns the file transfer mode.

Syntax

 object.BinMode[=Xfer As Boolean]
 

Type

Boolean. Returns TRUE for binary mode; otherwise, FALSE (ASCII mode).

Attributes

Read/write.

Remarks

Xfer is an optional parameter that sets the file transfer to binary mode (TRUE), or to ASCII mode (FALSE).

Example

This example sets file transfer to binary mode (TRUE).

 set ftpmgr = CreateObject("ucx:FTPFileMgr") 
 ftpmgr.Server = "193.97.54.165" 
 ftpmgr.Login ("User", "password") 
 print (ftpmgr.binmode) 
 ftpmgr.BinMode = True 
 ftpmgr.logout()
 

13.2.2 CurrentDir property

Returns an Entry object that represents the current working directory on a remote host.

Syntax

 object.CurrentDir
 

Type

Entry.

Attributes

Read-only.

Example

This example returns an Entry object that represents the current working directory on a remote host.

 set ftpmgr = createobject("ucx:FTPFileMgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 ftpmgr.logout()
 

13.2.3 LocalDir property

Returns the working directory on a local machine. By default, files will be transferred to this directory.

Syntax

 object.LocalDir
 

Type

String.

Attributes

Read-only.

Example

This example returns the working directory on a local machine.

 set ftpmgr = createobject("ucx:FTPFileMgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 print (ftpmgr.localdir) 
 ftpmgr.logout()
 

See Also

13.2.4 Port Property

Specifies the port number of the port used to connect to the FTP server.

Syntax

 Object.Port
 

Type

Integer.

Attributes

Read/Write.

Remarks

By default, the port number is set to 21.

The user can specify the port number and then call Login method.

Examples

This example sets the port number to 22.

 set ftpmgr = createobject("ucx:FTPFileMgr") 
 ftpmgr.port = 22
 ftpmgr.login ("User", "password") 
 print (ftpmgr.localdir) 
 ftpmgr.logout()
 

13.2.5 Server property

Sets or returns name or IP address of the remote host.

Syntax

 object.Server[=Address As String]
 

Type

String.

Attributes

Read/write.

Remarks

Address is an optional parameter that sets the IP address for the remote host.

Example

This example sets the IP address of the remote host to 193.97.54.165.

 set ftpmgr = createobject("ucx:FTPFileMgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 print (ftpmgr.localdir) 
 ftpmgr.logout()
 

13.2.6 TimeOut property

Sets or returns the timeout value, in seconds, for the FTP operation.

Syntax

 object.TimeOut[=Seconds As Integer]
 

Type

Integer.

Attributes

Read/write.

Remarks

Seconds is an optional parameter that sets the timeout value in seconds for the remote host (default=10).

Example

This example sets the timeout value of the remote host to 20 seconds.

 set ftpmgr = createobject("ucx:FTPFileMgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 ftpmgr.timeout=20 
 ftpmgr.logout()
 

See Also

13.2.7 Verbose property

Determines whether or not FTP operations are displayed on the current screen.

Syntax

 object.Verbose[=Value As Boolean]
 

Type

Boolean. Returns TRUE (default) if FTP operations are displayed on the current screen (shell); otherwise FALSE.

Attributes

Read/write.

Remarks

Value is an optional parameter that sets the verbose value. If set to TRUE, the FTP operations are displayed on the current screen (shell).

Example

This example causes FTP operations not to display on the current screen.

 set ftpmgr = createobject("ucx:FTPFileMgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.verbose = false 
 ftpmgr.login ("User", "password") 
 ftpmgr.logout()
 

See Also

13.2.8 ChangeDir method

Changes the current directory on the remote host.

Syntax

 object.ChangeDir(
    Path As String)
 

Parameters

Path
The path to the directory to change to. Can be either the absolute path or the relative path.

Return Values

Boolean. Returns TRUE if the change is successful; otherwise, FALSE.

Example

This example changes the current directory on the remote host to the Temp directory.

 set ftpmgr = createobject ("ucx:ftpfilemgr") 
      ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "Password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 ftpmgr.changeDir ("Temp") 
 print (ftpmgr.currentDir.Name) 
 ftpmgr.logout()
 

13.2.9 ChangeLocalDir method

Changes the current directory on the local host.

Syntax

 object.ChangeLocalDir(
    Path As String)
 

Parameters

Path
The path to the directory to change to. Can be either the absolute path or the relative path.

Return Values

Boolean. Returns TRUE if the change is successful; otherwise, FALSE.

Example

This example changes the current directory on the remote host to the Temp directory.

 set ftpmgr = createobject ("ucx:ftpfilemgr") 
      ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "Password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 ftpmgr.changelocaldir ("/Temp") 
 print (ftpmgr.localdir) 
 ftpmgr.logout()
 

13.2.10 FindEntry method

Finds an Entry object by path.

Syntax

 object.FindEntry(
    Path As String)
 

Parameters

Path
The path to the Entry object. Can be the absolute path or the relative path of the file or directory on the remote host.

Return Values

Entry. Returns the Entry object that corresponds to the path.

Example

This FindEntry example finds the file log.txt.

 set ftpmgr = createobject ("ucx:ftpfilemgr") 
      ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "Password") 
 set entry = ftpmgr.findentry ("/home/user/log.txt") 
 print ("File name: " &entry.name & "File Size: " &entry.size)
 

See Also

13.2.11 Login method

Logs a user in to the FTP server.

Syntax

 object.Login(
    UserName As String, 
    Password As String)
 

Parameters

UserName
The name of the user to log in.
Password
The user's password.

Return Values

Boolean. Returns TRUE if the login is successful; otherwise, FALSE.

Remarks

The Server property must be set prior to calling this function.

Example

This example logs User in to the FTP server. Notice that the Server property is set prior to calling the Login method.

 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "Password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 ftpmgr.changelocaldir ("/Temp") 
 print (ftpmgr.localdir) 
 ftpmgr.logout()
 

13.2.12 Logout method

Logs a user out of the FTP server.

Syntax

 object.Logout()
 

Parameters

None.

Return Values

Boolean. Returns TRUE if the logout is successful; otherwise, FALSE.

Example

This example logs User out of the FTP server.

 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "Password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 ftpmgr.changelocaldir ("/Temp") 
 print (ftpmgr.localdir) 
 ftpmgr.logout()
 

See Also