Xceed .NET Libraries Documentation
ItemCompletion Event


Xceed.FileSystem Assembly > Xceed.FileSystem Namespace > FileSystemEvents Class : ItemCompletion Event
Raised every time a FileSystemItem object has been processed, providing progression information to the event handler and the ability to perform custom post-processing on the target item.
Syntax
'Declaration
 
Public Event ItemCompletion As ItemProgressionEventHandler
'Usage
 
Dim instance As FileSystemEvents

Dim handler As ItemProgressionEventHandler

 

AddHandler instance.ItemCompletion, handler
public event ItemProgressionEventHandler ItemCompletion
Event Data

The event handler receives an argument of type ItemProgressionEventArgs containing data related to this event. The following ItemProgressionEventArgs properties provide information specific to this event.

PropertyDescription
Gets the total number of items being processed.  
The current FileSystemItem object being processed. (Inherited from Xceed.FileSystem.FileSystemEventArgs)
The destination FileSystemItem object being processed. (Inherited from )
Opaque data that is sent back to the event handler. (Inherited from )
Example

This example demonstrates how to use the ItemCompletion event to clear the "read only" attribute from files extracted from a zip archive.

static void ItemCompletionExample()

{

  /* Create a reference to a FileSystemEvents object */

  FileSystemEvents events = new FileSystemEvents();



  /* Subscribe to the ItemCompletion event of the FileSystemEvents object using the ItemProgressionEventHandler delegate */

  events.ItemCompletion += new ItemProgressionEventHandler( OnItemCompletion );



  // Get a reference to an existing zip file

  AbstractFile zipFile = new DiskFile( "ItemCompletionExample.zip" );

  System.Diagnostics.Debug.Assert( zipFile.Exists );

  Xceed.Zip.ZipArchive zip = new Xceed.Zip.ZipArchive( zipFile );



  // Select an output folder

  AbstractFolder destination = new DiskFolder( "Output" );



  // Extract the files from the archive using the events object

  zip.CopyFilesTo( events, null, destination, true, true );

}



/* Create a new method that will handle the events that are raised. For the purposes of this example, we will call the method OnItemProgression */

static void OnItemCompletion( object sender, ItemProgressionEventArgs e )

{

  /* Place the desired code in the newly created event handler */



  FileSystemItem targetItem = e.TargetItem;



  // Remove the read-only attribute from the target file

  FileAttributes attributes = targetItem.Attributes;

  targetItem.Attributes = ( attributes & ~FileAttributes.ReadOnly );

}
Private Shared Sub ItemCompletionExample()

  ' Create a reference to a FileSystemEvents object 

  Dim events As New FileSystemEvents()



  ' Subscribe to the ItemCompletion event of the FileSystemEvents object using the ItemProgressionEventHandler delegate 

  AddHandler events.ItemCompletion, AddressOf OnItemCompletion



  ' Get a reference to an existing zip file

  Dim zipFile As AbstractFile = New DiskFile("ItemCompletionExample.zip")

  System.Diagnostics.Debug.Assert(zipFile.Exists)

  Dim zip As New Xceed.Zip.ZipArchive(zipFile)



  ' Select an output folder

  Dim destination As AbstractFolder = New DiskFolder("Output")



  ' Extract the files from the archive using the events object

  zip.CopyFilesTo(events, Nothing, destination, True, True)

End Sub



' Create a new method that will handle the events that are raised. For the purposes of this example, we will call the method OnItemProgression 

Private Shared Sub OnItemCompletion(ByVal sender As Object, ByVal e As ItemProgressionEventArgs)

  ' Place the desired code in the newly created event handler 



  Dim targetItem As FileSystemItem = e.TargetItem



  ' Remove the read-only attribute from the target file

  Dim attributes As FileAttributes = targetItem.Attributes

  targetItem.Attributes = (attributes And (Not FileAttributes.ReadOnly))

End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also