2016-05-10 12 views
1

Wix Installer v3.9を使用してセットアップを作成しています。インストールが完了したら、「ファイルの参照」ダイアログをポップします。ユーザーはディレクトリから複数のファイルを選択できます。次に、これらのファイルパスをコマンドライン引数としてexeに渡す必要があります。 どうすればいいですか? Wix BrowseDlgを使用すると、ディレクトリのみを選択できます。Wixインストーラのファイルブラウズダイアログ

何か助けていただければ幸いです。

答えて

3

私が知る限り、wixツールセットはファイルブラウズコントロールを持っていません。 だから私は通常この仕事をするためにC#カスタムアクションを使用します。

このサンプルを試して、必要に応じてカスタマイズしてください。

using WinForms = System.Windows.Forms; 
using System.IO; 
using Microsoft.Deployment.WindowsInstaller; 

[CustomAction] 
public static ActionResult OpenFileChooser(Session session) 
{ 
    try 
    { 
     session.Log("Begin OpenFileChooser Custom Action"); 
     var task = new Thread(() => GetFile(session)); 
     task.SetApartmentState(ApartmentState.STA); 
     task.Start(); 
     task.Join(); 
     session.Log("End OpenFileChooser Custom Action"); 
    } 
    catch (Exception ex) 
    { 
     session.Log("Exception occurred as Message: {0}\r\n StackTrace: {1}", ex.Message, ex.StackTrace); 
     return ActionResult.Failure; 
    } 
    return ActionResult.Success; 
} 

private static void GetFile(Session session) 
{ 
    var fileDialog = new WinForms.OpenFileDialog { Filter = "Text File (*.txt)|*.txt" }; 
    if (fileDialog.ShowDialog() == WinForms.DialogResult.OK) 
    { 
     session["FILEPATH"] = fileDialog.FileName; 
    } 
} 
関連する問題