Xceed .NET Libraries Documentation
Listing the contents of a folder

Welcome to Xceed .NET, .NET Standard and Xamarin Libraries! > Basic Concepts > Xceed's FileSystem Core > Listing the contents of a folder

This topic demonstrates how to list the contents of a folder. With Xceed's FileSystem-based products, a folder is a folder: it does not matter if it is located within a zip file, on disk or in memory.

Basic steps

To list the contents of a folder, the following steps must be performed:

Demonstration

This example demonstrates how to list the contents of a folder located on disk.

VB.NET Copy Code

Imports Xceed.FileSystem

Dim folder As New DiskFolder( "c:\temp" )
Dim f As AbstractFile 

For Each f In folder.GetFiles( True )
   ListBox1.Items.Add( f.FullName )
Next

C# Copy Code

using Xceed.FileSystem;   

DiskFolder folder = new DiskFolder( @"c:\temp" );

foreach( AbstractFile f in folder.GetFiles( true ) )
{
   Console.WriteLine( f.FullName );
}   

Things you should consider

The main questions you should ask yourself when listing the contents of a folder are:

  • Do you want to filter (specify specific files and folders) the items that are to be listed? Use filters

  • Do you also want to retrieve a listing of the folders? Use the GetFolders method. 

  • Do you want to retrieve a listing of both files and folders? Use the GetItems method. 

  • Do you want to retrieve a reference to a single file or folder? Use the GetFile or GetFolder methods. 

  • Do you want to display the status of the operation? See the Events topic. 

  • Do you want to filter your list of files or folders? See the Filters topic.