13.4 Entries Collection

Enumerates the files and directories on the remote FTP host.

13.4.1 AddElement method

Creates a directory on the server.

Syntax

 object.AddElement(
    dirName As String)
 

Parameters

dirName
The name of the directory to create.

Return Values

Entry.

Example

This example creates the directory Regis.

 ’NSN example to print the details of files and directories on the remote host 
 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 set entries = currentDir.getchildren 
 set entry=entries.AddElement ("Regis") 
 print (entry.name &" " &entry.modifydate) 
 ftpmgr.logout()
 

13.4.2 Element method

Finds a file or directory by name.

Syntax

 object.Element(
    entryName As String)
 

Parameters

entryName
The name of the file or directory to find.

Return Values

Entry. Returns the specified Entry object if present; otherwise, NULL.

Remarks

The parameter, entryName, can be either the name of a file or the name of a directory.

Example

This example finds the file log.txt.

 ’NSN example to print the details of files and directories on the remote host 
 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 set entries = currentDir.getchildren 
 set entry=entries.Element ("log.txt") 
 print (entry.name &" " &entry.modifydate) 
 ftpmgr.logout()
 

13.4.3 Get method

Retrieves a file from FTP host computer and transfers it to the local computer.

Syntax

 object.Get(
    remoteFile As String, 
    [localFile As String],
 	   [restart As Boolean],
    [startPosition As Long],
    [numBytes As Long])
 

Parameters

remoteFile
The name of the file to retrieve.
localFile
Optional. The name by which the file must be saved on a local machine. If not specified, the local file name is the same as the remote file name.
restart
Optional. If set to TRUE, restarts the previous unsuccessful download. By default, the value is set to FALSE.
startposition
Optional. File download starting point.
numBytes
Optional. Number of bytes to be downloaded from the starting point.

Return Values

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

Remarks

If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.

Example

This example retrieves log.txt from the remote host and saves it to the local machine as logcopy.txt.

 ’NSN example to print the details of files and directories on the remote host 
 ’Get a copy of log.txt from remote host and save it as logcopy.txt
 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 set entries = currentDir.getchildren() 
 entries.Get ("log.txt", "logcopy.txt") 
 ftpmgr.logout()
 

13.4.4 HasMoreElements method

Determines whether or not the collection contains any more Entry objects.

Syntax

 object.HasMoreElements()
 

Parameters

None.

Return Values

Boolean. Returns TRUE if the collection contains more Entry objects; otherwise, FALSE.

Example

This HasMoreElements example determines whether or not the collection contains more Entry objects.

 ’NSN example to print the details of files and directories on the remote host 
 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 set entries = currentDir.getchildren 
 entries.reset()
 while (entries.hasmoreelements) 
      set Entry=entries.next 
      print (entry.name &" " &entry.modifydate) 
 wend 
 ftpmgr.logout()
 

13.4.5 Next method

Returns the next Entry object in the Entries collection.

Syntax

 object.Next()
 

Parameters

None.

Return Values

Entry. Returns the next Entry object in the collection.

Example

This Next example returns the next Entry object in the collection.

 ’NSN example to print the details of files and directories on the remote host 
 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 set entries = currentDir.getchildren 
 entries.reset 
 while (entries.hasmoreelements) 
      set Entry=entries.next 
      print (entry.name &" " &entry.modifydate) 
 wend 
 ftpmgr.logout()
 

13.4.6 Put method

Copies a local file to the remote FTP host.

Syntax

 object.Put(
    localFile As String, 
    [remoteFile As String])
 

Parameters

localFile
The name of the file to copy.
remoteFile
Optional. The name by which the file must be saved on a remote machine. If not specified, the remote file name is the same as the local file name.

Return Values

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

Remarks

If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.

Example

This example copies localfl.txt from the local machine and saves it to the remote machine as localfl.txt.

 ’Copy a file from local machine to remote host 
 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 set entries = currentDir.getchildren() 
 entries.Put ("localfl.txt") 
 ftpmgr.logout()
 

13.4.7 RemoveElement method

Deletes the specified Entry object from the collection.

Syntax

 object.RemoveElement(
    entryName As String)
 

Parameters

entryName
The name of the file or directory to delete.

Return Values

Boolean. Returns TRUE if the Entry object is successfully removed; otherwise, FALSE.

Remarks

The entryName parameter can be either the name of a file or the name of a directory.

Example

This example removes the file Regis from the collection.

 ’NSN example to remove a file on the remote host 
 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 set entries = currentDir.getchildren 
 entries.RemoveElement ("Regis") 
 ftpmgr.logout()
 

13.4.8 Reset method

Resets the collection of Entry objects.

Syntax

 object.Reset()
 

Parameters

None.

Return Values

Void.

Example

This example resets the collection of Entry objects.

 ’NSN example to print the details of files and directories on the remote host 
 set ftpmgr = createobject ("ucx:ftpfilemgr") 
 ftpmgr.server = "193.97.54.165" 
 ftpmgr.login ("User", "password") 
 set currentDir = ftpmgr.currentDir 
 print (currentDir.Name) 
 set entries = currentDir.getchildren 
 entries.reset 
 while (entries.hasmoreelements) 
      set Entry=entries.next 
      print (entry.name &" " &entry.modifydate) 
 wend 
 ftpmgr.logout()