例如,我想将包含setup.exe
的应用程序部署到自解压存档中。当用户执行自解压存档时,它会将内容解压缩到临时文件夹并运行setup.exe。
这可能吗?如果是这样,有什么例子吗?
答案 0 :(得分:2)
是的,这是你可以用DotNetZip
做的事情之一。
文档页面提供了一个示例 SaveSelfExtractor Method (exeToGenerate, options)
string DirectoryPath = "c:\\Documents\\Project7";
using (ZipFile zip = new ZipFile())
{
zip.AddDirectory(DirectoryPath, System.IO.Path.GetFileName(DirectoryPath));
zip.Comment = "This will be embedded into a self-extracting WinForms-based exe";
var options = new SelfExtractorSaveOptions
{
Flavor = SelfExtractorFlavor.WinFormsApplication,
DefaultExtractDirectory = "%USERPROFILE%\\ExtractHere",
PostExtractCommandLine = ExeToRunAfterExtract,
SfxExeWindowTitle = "My Custom Window Title",
RemoveUnpackedFilesAfterExecute = true
};
zip.SaveSelfExtractor("archive.exe", options);
}