How to provide write access on Installed Folder

Apr 13, 2015 at 2:07 AM
Hi,

As part of out error logging in our application, we are creating a ".log" file at the installed location. @programFiles\ApplicationName\ Error.Log

Using Wix, we used to achieve this by writing below code.
<Directory Id="Root" Name="Application Name">
      <Component Id="ProductComponent" Guid="BB6928A8-D046-4A31-A484-493693296AC3">
        <CreateFolder>
          <Permission User="Everyone" GenericAll="yes" />
        </CreateFolder>            
      </Component>
Can you please help on how to provide similar access using Wix C#. Currently error log is not getting created.

Thanks in Advance.
Apr 13, 2015 at 6:14 AM
Edited Apr 13, 2015 at 6:26 AM
class Script
{
    static public void Main()
    {
        var project =
            new Project("MyProduct",
                new Dir(@"%ProgramFiles%\My Company\My Product",
                    new File(@"Files\Bin\MyApp.exe"),
                    new Dir(@"Docs\Manual",
                        new File(@"Files\Docs\Manual.txt"))));

        project.UI = WUI.WixUI_InstallDir;
        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");

        Compiler.WixSourceGenerated += Compiler_WixSourceGenerated;
        Compiler.BuildMsiCmd(project);
    }

    static void Compiler_WixSourceGenerated(XDocument document)
    {
        document.Descendants("Component")
                .Single(x => x.HasAttribute("Id", value => value.EndsWith("MyApp.exe")))
                .Add(new XElement("CreateFolder",
                         new XElement("Permission", "User=Everyone;GenericAll=yes")));
    }
}
But I hope you realize that giving the write access to the ProgramFiles sub-folder goes against all deployment guidelines. :)
Apr 14, 2015 at 4:29 AM
Thank you very much :)