Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us

Transaction Example

Top 

The following example shows how to use transaction system:

 

 

[C#]

flexCompress1.FileName = "C:\\TEST\\test.fxc";

// Create a new archive file           

flexCompress1.OpenArchive(System.IO.FileMode.Create);

// Start a transaction

flexCompress1.BeginUpdate();

// Set path to folder with some HTML files to BaseDir

flexCompress1.BaseDir = DemoPath + "Source";

// Add all files from Source folder to the archive

try

{

       flexCompress1.AddFiles("*.*");

}

catch

{

       // If errors occurs rollback transaction. All modifications will be cancelled.           

       flexCompress1.CancelUpdate();

       // Close archive and exit current procedure               

       flexCompress1.CloseArchive();

       MessageBox.Show("Error adding all files");

       return;

}

// Set path to folder with some HTML files to BaseDir           

flexCompress1.BaseDir = DemoPath + "Source1\\";

// Add all HTML files from Source1 folder to the archive

try

{

       flexCompress1.AddFiles("*.htm*");

}

catch

{

       // If errors occurs rollback transaction. All modifications will be cancelled.               

       flexCompress1.CancelUpdate();

       // Close archive and exit current procedure               

       flexCompress1.CloseArchive();

     MessageBox.Show("Error adding html files");

     return;

}

// Commit a transaction. All modifications will be saved.           

flexCompress1.EndUpdate();

// Set path to destination folder           

flexCompress1.BaseDir = DemoPath + "Dest";

// Extract all files           

flexCompress1.ExtractFiles("*.*");

// Close the archive           

flexCompress1.CloseArchive();

 

 

[VB.NET]

flexCompress1.FileName = "C:\TEST\test.fxc";

' Create a new archive file           

flexCompress1.OpenArchive(System.IO.FileMode.Create)

' Start a transaction

flexCompress1.BeginUpdate()

' Set path to folder with some HTML files to BaseDir

flexCompress1.BaseDir = DemoPath + "Source"

' Add all files from Source folder to the archive

Try

       flexCompress1.AddFiles("*.*")

Catch

       ' If errors occurs rollback transaction. All modifications will be cancelled.           

     flexCompress1.CancelUpdate()

     ' Close archive and exit current procedure               

     flexCompress1.CloseArchive()

     MessageBox.Show("Error adding all files")

     Return

End Try

' Set path to folder with some HTML files to BaseDir           

flexCompress1.BaseDir = DemoPath + "Source1\\"

' Add all HTML files from Source1 folder to the archive

Try

       flexCompress1.AddFiles("*.htm*")

Catch

       ' If errors occurs rollback transaction. All modifications will be cancelled.               

     flexCompress1.CancelUpdate()

     ' Close archive and exit current procedure               

     flexCompress1.CloseArchive()

     MessageBox.Show("Error adding html files")

       Return

End Try

' Commit a transaction. All modifications will be saved.           

flexCompress1.EndUpdate()

' Set path to destination folder           

flexCompress1.BaseDir = DemoPath + "Dest"

' Extract all files           

flexCompress1.ExtractFiles("*.*")

' Close the archive           

flexCompress1.CloseArchive()

 

 

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 22, 2024