我的HyperlinkLargeTheme.xml中有以下代码:
<Editbox Name="InstallDir" X="11" Y="143" Width="-91" Height="21" TabStop="yes" FontId="3" FileSystemAutoComplete="yes">[InstallDir]</Editbox>
<Button Name="BrowseButton" X="-11" Y="142" Width="75" Height="23" TabStop="yes" FontId="3">Browse</Button>
下面是如何在 C# 中使用引导程序的代码:
var bootstrapper =
new Bundle(ProductInformation.ProductName, netPckg, cppRedistributables, erlangPackage, rabbitMqPackage, sdkPackage, webPackage)
{
OutFileName = ProductInformation.ProductName,
Manufacturer = ProductInformation.Manufacturer,
Version = new Version(ProductInformation.Version),
UpgradeCode = new Guid(ProductInformation.UpgradeCodeBundle),
StringVariablesDefinition = @"InstallDir=[ProgramFilesFolder][WixBundleManufacturer];ServerIp=127.0.0.1;ServerPort=12543;DbConnStr=;WebSitePort=80"
};
bootstrapper.DisableModify = "yes";
bootstrapper.IncludeWixExtension(WixExtension.Util);
bootstrapper.Application.LogoFile = @"Images\WizardSmallImageFile.bmp";
bootstrapper.Application.Attributes.Add("ThemeFile", @"Theme\HyperlinkLargeTheme.xml");
bootstrapper.Application.LocalizationFile = @"Theme\HyperlinkTheme.wxl";
bootstrapper.WixSourceGenerated += Bootstrapper_WixSourceGenerated;
bootstrapper.IconFile = ProductInformation.IconFile;
bootstrapper.OutFileName = ProductInformation.ProductName + " " + ProductInformation.Version;
bootstrapper.OutDir = AppDomain.CurrentDomain.BaseDirectory;
bootstrapper.PreserveTempFiles = true;
var productMsi = bootstrapper.Build();
然后安装程序使用编辑框的内容将文件放在正确的目标位置。但是,当使用 BrowseButton 浏览文件夹时,编辑框的内容不会改变。如果我将 Editbox 的 name 属性更改为“FolderEditbox”,则浏览按钮将正常工作,但是无论编辑框的内容如何,文件都会安装到默认安装目录中。如何完成使用按钮浏览和安装到所选目录?