Wix Installer的自定义操作未创建文件夹

时间:2019-04-23 21:39:06

标签: c# wix custom-action

使用Wix安装程序的“自定义操作”未在本地磁盘C中创建文件夹。

namespace MyCustomAction
{
    public class CustomActions
    {
        [CustomAction]
        public static ActionResult MySimpleAction(Session session)
        {
            string country = session["COUNTRIES"];

            string root = @"C:\Temp";

            try
            {

                if (!Directory.Exists(root))
                {
                   System.IO.Directory.CreateDirectory(root);
                    File.AppendAllText(@"C:\Temp\country.txt", country);
                }

            }
            catch (Exception)
            {
                return ActionResult.Failure;
            }
            return ActionResult.Success;
        }
    }
}

0 个答案:

没有答案