Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create Self-Extracting EXE in C#
This is a simple example demonstrating how to create a self-extracting EXE in C#. It zips a directory tree and creates a .exe that can be run without the .NET runtime or any system DLLs (it is completely standalone).
private void CreateExe_Click(object sender, System.EventArgs e)
{
// If this does not compile or work correctly,
// download and install the latest version
// of Chilkat .NET and try again. Some of the
// self-extracting EXE properties, such as AutoTemp
// were added in a recent version.
Chilkat.Zip zip = new Chilkat.Zip();
zip.UnlockComponent("30-day trial");
// We will never actually write test.zip, because
// we'll be writing a self-extracting EXE instead.
zip.NewZip("test.zip");
zip.AppendFiles("./SendMail",true);
// Set AutoTemp to true if you wish the EXE to automatically
// unzip into a auto-selected temp directory when the EXE
// is run.
//zip.AutoTemp = true;
// Set AutoRun to the name of an EXE within the
// archive to automatically run it after the
// self-extracting EXE is unzipped.
//zip.AutoRun = "setup.exe";
// Set the title bar for the EXE
zip.ExeTitle = "This is my self-extracting EXE";
// Write a self-extracing EXE. The LastError
// property will contain error information if
// it fails
if (!zip.WriteExe("test.exe"))
{
textBox1.Text = zip.LastErrorText;
}
else
{
textBox1.Text = "Self-extracting EXE successfully created!";
}
// Make sure all resources are released.
zip.CloseZip();
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.