Xceed .NET Libraries Documentation
DiskRequired Event
Example 


Xceed.Zip Assembly > Xceed.Zip Namespace > ZipEvents Class : DiskRequired Event
Raised when a new disk or split part is required.
Syntax
'Declaration
 
Public Event DiskRequired As DiskRequiredEventHandler
'Usage
 
Dim instance As ZipEvents
Dim handler As DiskRequiredEventHandler
 
AddHandler instance.DiskRequired, handler
public event DiskRequiredEventHandler DiskRequired
Event Data

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

PropertyDescription
Gets or sets a value indicating if the current operation should be aborted or if it should attempt to continue.  
Gets or sets the current FileSystemItem object being processed. (Inherited from Xceed.FileSystem.FileSystemEventArgs)
Gets the number of the next required disk.  
Gets a DiskRequiredReason value indicating the reason why a new disk is required.  
Gets or sets a value representing the size, in bytes, of the next split part to be created in the case where the zip file is being split (not necessarily spanned).  
Gets or sets the destination Xceed.FileSystem.FileSystemItem object. (Inherited from )
Gets or sets the opaque data that will be sent back to the event handler whenever an event is raised. (Inherited from )
Gets or sets the next zip file to write to or read from.  
Example
The following example demonstrates how to create a spanned zip file.
Imports Xceed.Zip
Imports Xceed.FileSystem

Dim source As New DiskFolder( "c:\windows\fonts" )
Dim WithEvents zipEvents As New ZipEvents()

AddHandler zipEvents.DiskRequired, AddressOf Me.OnDiskRequired

Dim zip As New ZipArchive( zipEvents, Nothing, New DiskFile( "a:\test.zip" ) )

zip.AllowSpanning = true
source.CopyFilesTo( zip, true, true )

' This method will handle the DiskRequired events that are raised.
'
' The code contained within this method is the suggested implementation to use when spanning.
Private Sub OnDiskRequired( ByVal sender As Object, ByVal e As DiskRequiredEventArgs )
      If e.Action = DiskRequiredAction.Fail Then
            If MessageBox.Show( "Disk #" + e.DiskNumber.ToString() + " is required.", _
                                "Disk Required", _
                                MessageBoxButtons.OKCancel ) = DialogResult.OK Then
                  e.Action = DiskRequiredAction.Continue
            Else
                  e.Action = DiskRequiredAction.Fail
            End If
      End If
End Sub
using Xceed.Zip;
using Xceed.FileSystem;

DiskFolder source = new DiskFolder( @"c:\windows\fonts" );

ZipEvents zipEvents = new ZipEvents();
zipEvents.DiskRequired += new DiskRequiredEventHandler( this.OnDiskRequired );
ZipArchive zip = new ZipArchive( zipEvents, null, new DiskFile( @"a:\test.zip" ) );

zip.AllowSpanning = true;
source.CopyFilesTo( zip, true, true ); 

// This method will handle the DiskRequired events that are raised.
//
// The code contained within this method is the suggested implementation to use when spanning.
private void OnDiskRequired( object sender, DiskRequiredEventArgs e )
{    
        if( e.Action == DiskRequiredAction.Fail )
        {
                if( MessageBox.Show( "Disk #" + e.DiskNumber.ToString() + 
                                     " is required.", "Disk Required", 
                                     MessageBoxButtons.OKCancel ) == DialogResult.OK )
                        e.Action = DiskRequiredAction.Continue;
                else
                        e.Action = DiskRequiredAction.Fail;
        }
}
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