Xceed .NET Libraries Documentation
ScanningFolder event

Welcome to Xceed .NET, .NET Standard and Xamarin Libraries! > Basic Concepts > Events > ScanningFolder event

The ScanningFolder event is raised whenever a folder is scanned for matching items while building a list of items to process.

Purpose

The main purpose of the ScanningFolder event is to prevent your application from appearing frozen during long operations. For example, if you  were to handle the ByteProgression event in conjunction with the ScanningFolder event, the ScanningFolder event could return information on the folders being scanned during the first pass of the ByteProgression event.

Basic steps - C#

To subscribe to the ScanningFolder event, the following steps must be performed:

Basic steps - VB.NET

To subscribe to the ScanningFolder event, the following steps must be performed:

Demonstration

This example demonstrates how to copy files to a folder located on disk and display progress information while the folder are being scanned.

VB.NET Copy Code

Imports Xceed.FileSystem

Dim WithEvents fiEvents As New FileSystemEvents()
Dim folder As New DiskFolder("c:\temp")

folder.CopyFilesTo( fiEvents, Nothing, New DiskFolder( "c:\destination" ), True, True ) 

Private Sub fiEvents_ScanningFolder( ByVal sender As Object, -
                                     ByVal e As Xceed.FileSystem.ScanningFolderEventArgs ) Handles fiEvents.ScanningFolder

  ListBox1.Items.Add("Scanning " + e.CurrentItem.Name)
End Sub

C# Copy Code
using Xceed.FileSystem;
 
FileSystemEvents fiEvents = new FileSystemEvents();
fiEvents.ScanningFolder += new ScanningFolderEventHandler( OnScanningFolder );
 
DiskFolder folder = new DiskFolder( @"c:\temp" );
folder.CopyFilesTo( fiEvents, null, new DiskFolder( @"c:\destination" ), true, true );
 
//This method will handle the ScanningFolder events that are raised.
public static void OnScanningFolder( object sender, ScanningFolderEventArgs e )
{
  Console.WriteLine( "Scanning " + e.CurrentItem.Name );
}
 
//If you no longer wish to handle the events that are raised,
//you can unsubscribe from the event notifications by doing the following:
 
fiEvents.ScanningFolder -= new ScanningFolderEventHandler( OnItemException );