PowerTCP Zip Compression for .NET
from $299.00Available Platforms
See all PowerTCP Zip Compression for .NET Code Examples
Self-Extracting File Example
The following C# example demonstrates creation of a self-extracting file using the Archive component.
private void buttonCreateSelfExtract_Click(object sender, EventArgs e)
{
try
{
//Add a folder to the zip file.
//Include subfolders and preserve paths.
archive1.IncludeSubs = true;
archive1.PreservePath = true;
archive1.Add("c:\\MyFiles\\*");
//Set the self-extract parameters.
archive1.SelfExtractConfiguration = new SelfExtractConfiguration();
archive1.SelfExtractConfiguration.CodePage = archive1.Encoding.CodePage;
archive1.SelfExtractConfiguration.Caption = "My Self-Extracting File";
archive1.SelfExtractConfiguration.Behavior = SelfExtractBehavior.UserInteractive;
//No extracted file opened after archive is unzipped.
archive1.SelfExtractConfiguration.FileToExecute = "";
//Default overwrite behavior (can be changed by user).
archive1.SelfExtractConfiguration.Overwrite = Overwrite.Always;
archive1.SelfExtractConfiguration.EnableOverwrite = true;
//Paths are preserved (cannot be changed by user).
archive1.SelfExtractConfiguration.PreservePath = true;
archive1.SelfExtractConfiguration.EnablePreservePath = false;
//Path to archive to (can be changed by user).
archive1.SelfExtractConfiguration.Path = "c:\\YourFiles";
archive1.SelfExtractConfiguration.EnablePath = true;
//Create the zip file.
archive1.Zip("c:\\MyArchive\\mySelfExtractingFile.exe");
}
catch (Exception ex)
{
//Display message if operation encounters an error.
textWarnings.AppendText("Error: " + ex.Message + Environment.NewLine);
}
}
private void archive1_Exception(object sender, Dart.PowerTCP.Zip.ExceptionEventArgs e)
{
//Display any warnings that occur during the operation.
textWarnings.AppendText("Warning: " + archive1[e.Index].Name + " - " +
e.Exception.Message + Environment.NewLine);
}
The PowerTCP Zip Compression for .NET Compress a Folder example is included with a trial installation of PowerTCP Zip Compression for .NET. To download a trial please visit the PowerTCP Zip Compression for .NET product page.