Xceed FTP Library Documentation
XceedFtpFolderItems collection
XceedFtp control reference > Optional objects and interfaces > XceedFtpFolderItems collection

The XceedFtpFolderItems object is returned by the GetFolderContents method. It contains a static collection of items that represent the contents of a remote folder. Each item in the collection is an XceedFtpFolderItem object, which provides information on one file, folder or link.

The XceedFtpFolderItems object exposes the IEnumVARIANT interface. The IEnumVARIANT interface is a standard COM interface for enumerating items in a collection or list. Some development languages automatically detect when an object supports this interface and offer easy access to the collection's contents. If your language doesn't support IEnumVARIANT directly, obtain an interface pointer and see the declaration of the interface's methods at the end of this topic.

Please keep in mind that you can obtain a remote folder's contents through events, and it is not necessary to use the XceedFtpFolderItems collection object. See the ListFolderContents method alternative to GetFolderContents.

Visual Basic Copy Code

' Visual Basic detects the implementation of the IEnumVARIANT interface and allows
' you to access the collection using the For Each statement, like this: 

Dim FolderItems As XceedFtpFolderItems ' The collection
Dim FolderItem As XceedFtpFolderItem ' One item 

' (code to connect to FTP server skipped)
Set FolderItems = XceedFtp1.GetFolderContents("", fcfCollection) ' Fill collection 

For Each FolderItem In FolderItems
  Debug.print FolderItem.ItemName & " size=" & FolderItem.FileSize
Next FolderItem 

'See complete VB example.

Delphi Copy Code

{Delphi can use the XceedFtpFolderItems object via the object's Count and Item properties, like this:}

var   FolderItems : XceedFtpFolderItems; {The collection} 
   FolderItem : XceedFtpFolderItem; {One item} 
   ItemIndex : integer; {Index variable} 
   vaIndex : OleVariant; {Index as a variant} 
begin
   { code to connect to FTP server skipped } 
   FolderItems := XceedFtp1.GetFolderContents('', fcfCollection); {Fill collection} 
   ItemIndex := 1; {Starting item}  

   while ItemIndex <= FolderItems.Count do {Loop through items} 
   begin 
      vaIndex := ItemIndex; {Convert to variant} 
      FolderItem := FolderItems.Item[ vaIndex ]; {Get current item} 

      ListBox1.Items.Add(FolderItem.ItemName); {Display item name} 
      nItemIndex := nItemIndex + 1; {Go to next item} 
   end; 
{See complete Delphi example.}

Visual C++ with ATL Copy Code

// Visual C++ can use the XceedFtpFolderItems object via the object's Count and Item
// properties, like this:

IXceedFtpFolderItemsPtr piFolderItems; // pointer to collection
IXceedFtpFolderItemPtr piItem; // pointer to one item

_bstr_t sName; 

// code to connect to FTP server skipped
piFolderItems = piXceedFtp->GetFolderContents( _bstr_t( "" ), fcfCollection);

for( long lIndex = 1; lIndex <= piFolderItems->Count; lIndex++ )
{
   piItem = piFolderItems->Item[ &_variant_t( lIndex ) ]; 
   sName = piItem->GetItemName(); 
   printf( "%S\n", ( const WCHAR* )sName ); 

//See complete ATL example.

 
IEnumVARIANT declaration (read-only properties)  

[propget] HRESULT Item([in] VARIANT* vaIndex,

[out, retval] IXceedFtpFolderItem** pVal); 

[propget] HRESULT Count([out, retval] long* pVal);

ProgID

XceedSoftware.XceedFtp.XceedFtpFolderItems.1