An System.Int32 value that represents the number of times certain operations will be automatically retried. The default value is 0.
Remarks
No retries will be attempted if the value of the 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 AutoRetryDelay Property, the temporary file operations will be tried again, giving the conflicting application time to finish its work.
publicstaticvoid 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 );
}
}
PublicSharedSub 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()
EndIf' Create a logical zip archive around the zip file
Dim zip AsNew ZipArchive(zipFile)
' Wrap the operations that modify the zip archive in a batch update
Using batch AsNew 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)
EndUsing' Wrap the operations that modify the zip archive in a batch update
Using batch AsNew 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)
EndUsingEnd 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