0

Folder not getting created in Local Disk C using Custom Action of a Wix Installer.

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;
        }
    }
}
Anthony
  • 3,595
  • 2
  • 29
  • 38
  • What does the installer log show? Is your custom action executed? Does it have any exceptions logged? – Christopher Painter Apr 23 '19 at 22:13
  • Just in case you want [some information on how to hook up the debugger](https://stackoverflow.com/a/52880033/129130). Check the video from Advanced Installer. But more than that, what are you doing there with that country.txt file? There might be better ways to do it. – Stein Åsmul Apr 23 '19 at 23:16
  • The installer shows no error. I am saving the item selected from the combo box list (that appears in the dialogue of the wix installer) in the country.txt file. But I am not able to create the temp folder from the above code and for now I am creating it manually. Is there a way to create a folder using a Custom Action.Moreover, is there also a way to make my combo box selection compulsory in wix installer dialogue? @SteinÅsmul,@Christopher Painter – user11350030 Apr 24 '19 at 04:36
  • I have to use Wix installer only. – user11350030 Apr 24 '19 at 05:05
  • The video from Advanced Installer is a general purpose video of how to debug custom actions, it has validity even if you use WiX. Could you write the selection from that combo box to the registry instead? – Stein Åsmul Apr 24 '19 at 11:33
  • 2
    I didn't ask what the installer said. I asked what the installer log shows. You don't show the WiX code that defines and sequences the custom action that calls this code so I don't have any way of know that this custom action is even being called. – Christopher Painter Apr 24 '19 at 12:26
  • Thanks for the responses my Custom Action is working now. – user11350030 Apr 25 '19 at 05:41

0 Answers0