Xceed .NET Libraries Documentation
AutoRetryDelay Property


Xceed.Zip Assembly > Xceed.Zip Namespace > ZipArchive Class : AutoRetryDelay Property
Gets or sets the amount of milliseconds to wait before certain operations will be automatically retried when an exception occurs.
Syntax
'Declaration
 
Public Shared Property AutoRetryDelay As Integer
'Usage
 
Dim value As Integer

 

ZipArchive.AutoRetryDelay = value

 

value = ZipArchive.AutoRetryDelay
public static int AutoRetryDelay {get; set;}

Property Value

An System.Int32 value that represents the amount of milliseconds to wait before certain operations will be automatically retried when an exception occurs. The default value is 200.
Remarks

This property is ignored if the value of the NumAutoRetries Property is zero or less.

Automatic retries currently only apply to operations where a zip archive is updated and the required temporary files fail to be moved, renamed or deleted.

This usually happens because another service or application, antivirus software for example, have locked the files.

Combined with the NumAutoRetries Property, the temporary file operations will be tried again, giving the conflicting application time to finish its work.

Example
public static void AutoRetry()

{

  // Enable auto retries by asking for 5 retries

  ZipArchive.NumAutoRetries = 5;



  // Set up a delay of 200ms between retries

  ZipArchive.AutoRetryDelay = 200;



  // Select a file that will be our zip file

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



  // If the zip file already exists

  if( zipFile.Exists )

    // Delete it

    zipFile.Delete();



  // Create a logical zip archive around the zip file

  ZipArchive zip = new ZipArchive( zipFile );



  // Wrap the operations that modify the zip archive in a batch update

  using( AutoBatchUpdate batch = new AutoBatchUpdate( zip ) )

  {

    // Select an individual file

    AbstractFile sourceFile = new DiskFile( @"SomeFile.dat" );



    // Select a specific target name and path for the file in the archive

    AbstractFile targetFile = zip.GetFile( @"MyFolder1\MyFolder2\MyNamedFile.mydata" );



    // Zip it to the archive

    sourceFile.CopyTo( targetFile, true );

  }



  // Wrap the operations that modify the zip archive in a batch update

  using( AutoBatchUpdate batch = new AutoBatchUpdate( zip ) )

  {

    // Select an individual file

    AbstractFile sourceFile = new DiskFile( @"SomeOtherFile.dat" );



    // Select a specific target name and path for the file in the archive

    AbstractFile targetFile = zip.GetFile( @"MyFolder1\MyFolder2\MyNamedFile.mydata" );



    /* We will now update the existing item in the archive. If the temporary files

       somehow cannot be moved, renamed or deleted because of interference from another

       application, the component will retry because we set the 'auto retry' properties

       above.

       

       Note that this will happen during the closure of the AutoBatchUpdate block we are

       in. */



    // Update the item in the archive

    sourceFile.CopyTo( targetFile, true );

  }

}
    Public Shared Sub AutoRetry()

      ' Enable auto retries by asking for 5 retries

      ZipArchive.NumAutoRetries = 5



      ' Set up a delay of 200ms between retries

      ZipArchive.AutoRetryDelay = 200



      ' Select a file that will be our zip file

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



      ' If the zip file already exists

      If zipFile.Exists Then

        ' Delete it

        zipFile.Delete()

      End If



      ' Create a logical zip archive around the zip file

      Dim zip As New ZipArchive(zipFile)



      ' Wrap the operations that modify the zip archive in a batch update

      Using batch As New AutoBatchUpdate(zip)

        ' Select an individual file

        Dim sourceFile As AbstractFile = New DiskFile("SomeFile.dat")



        ' Select a specific target name and path for the file in the archive

        Dim targetFile As AbstractFile = zip.GetFile("MyFolder1\MyFolder2\MyNamedFile.mydata")



        ' Zip it to the archive

        sourceFile.CopyTo(targetFile, True)

      End Using



      ' Wrap the operations that modify the zip archive in a batch update

      Using batch As New AutoBatchUpdate(zip)

        ' Select an individual file

        Dim sourceFile As AbstractFile = New DiskFile("SomeOtherFile.dat")



        ' Select a specific target name and path for the file in the archive

        Dim targetFile As AbstractFile = zip.GetFile("MyFolder1\MyFolder2\MyNamedFile.mydata")



'         We will now update the existing item in the archive. If the temporary files

'           somehow cannot be moved, renamed or deleted because of interference from another

'           application, the component will retry because we set the 'auto retry' properties

'           above.

'           

'           Note that this will happen during the closure of the AutoBatchUpdate block we are

'           in. 



        ' Update the item in the archive

        sourceFile.CopyTo(targetFile, True)

      End Using

    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

Reference

ZipArchive Class
ZipArchive Members
NumAutoRetries Property