The following example shows how to use transaction system:
[C#]
zipForge1.FileName = "C:\\TEST\\test.zip";
// Create a new archive file
zipForge1.OpenArchive(System.IO.FileMode.Create);
// Start a transaction
zipForge1.BeginUpdate();
// Set path to folder with some HTML files to BaseDir
zipForge1.BaseDir = DemoPath + "Source";
// Add all files from Source folder to the archive
try
{
zipForge1.AddFiles("*.*");
}
catch
{
// If errors occurs rollback transaction. All modifications will be cancelled.
zipForge1.CancelUpdate();
// Close archive and exit current procedure
zipForge1.CloseArchive();
MessageBox.Show("Error adding all files");
return;
}
// Set path to folder with some HTML files to BaseDir
zipForge1.BaseDir = DemoPath + "Source1\\";
// Add all HTML files from Source1 folder to the archive
try
{
zipForge1.AddFiles("*.htm*");
}
catch
{
// If errors occurs rollback transaction. All modifications will be cancelled.
zipForge1.CancelUpdate();
// Close archive and exit current procedure
zipForge1.CloseArchive();
MessageBox.Show("Error adding html files");
return;
}
// Commit a transaction. All modifications will be saved.
zipForge1.EndUpdate();
// Set path to destination folder
zipForge1.BaseDir = DemoPath + "Dest";
// Extract all files
zipForge1.ExtractFiles("*.*");
// Close the archive
zipForge1.CloseArchive();
[VB.NET]
zipForge1.FileName = "C:\TEST\test.zip";
' Create a new archive file
zipForge1.OpenArchive(System.IO.FileMode.Create)
' Start a transaction
zipForge1.BeginUpdate()
' Set path to folder with some HTML files to BaseDir
zipForge1.BaseDir = DemoPath + "Source"
' Add all files from Source folder to the archive
Try
zipForge1.AddFiles("*.*")
Catch
' If errors occurs rollback transaction. All modifications will be cancelled.
zipForge1.CancelUpdate()
' Close archive and exit current procedure
zipForge1.CloseArchive()
MessageBox.Show("Error adding all files")
Return
End Try
' Set path to folder with some HTML files to BaseDir
zipForge1.BaseDir = DemoPath + "Source1\\"
' Add all HTML files from Source1 folder to the archive
Try
zipForge1.AddFiles("*.htm*")
Catch
' If errors occurs rollback transaction. All modifications will be cancelled.
zipForge1.CancelUpdate()
' Close archive and exit current procedure
zipForge1.CloseArchive()
MessageBox.Show("Error adding html files")
Return
End Try
' Commit a transaction. All modifications will be saved.
zipForge1.EndUpdate()
' Set path to destination folder
zipForge1.BaseDir = DemoPath + "Dest"
' Extract all files
zipForge1.ExtractFiles("*.*")
' Close the archive
zipForge1.CloseArchive()