我有一个wix安装程序,并使用OpenFileDialog允许用户选择文件,所选文件需要存储在会话变量中以显示在安装程序的列表框中
无法在会话变量中存储列表或数组
OpenFileDialog
public static string[] ListFiles()
{
using (WinForms.OpenFileDialog file = new WinForms.OpenFileDialog())
{
//Allow to select multiple files
file.Multiselect = true;
//Allow to select only *.txt Files
file.Filter = "Only SQL files | *.sql";
//Show the Dialog box to selcet file(s)
file.ShowDialog();
//return input file names
return file.FileNames;
}
}
session["SQL_FILEPATH"] = ListFiles();
This line throws an exception as the session only allows string to be stored.
WiX控件
<Control Id="SqlFiles" Property="SQL_FILEPATH" Type="ListBox" X="20" Y="150" Width="200" Height="52" Sorted="yes">
<ListBox Property="SQL_FILEPATH">
<ListItem Text="[SQL_FILEPATH]" Value="[SQL_FILEPATH]"/>
</ListBox>
</Control>
列表框应显示所有选定的文件名及其路径。