How to create a directory in wix?

给你一囗甜甜゛ 提交于 2019-11-29 01:02:12

Define the folder like this:

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="CommonAppDataFolder">
        <Directory Id="TestFolder" Name="test">
            <Directory Id="ExampleFolder" Name="example" />
        </Directory>
    </Directory>
</Directory>

The important part here is the CommonAppDataFolder Id, which is known by Windows installer. You can find the full list of known system folders in the Windows Installer Property Reference.

If you install any files to that folder, it will be created implicitly. If not, you can force it to be created by installing a component like this:

<Component Id="CreateTestFolder" Directory="ExampleFolder" Guid="PUT-RANDOM-GUID-HERE">
    <CreateFolder />
</Component>

Under <Product> you can enter:

   <DirectoryRef Id="TARGETDIR">
      <Directory Id="CommonAppDataFolder">
        <Directory Id="CommonAppXXXX" Name="test">
          <Directory Id="CommonAppYYYY" Name="example">
            <Component Id="CreateProgramDataZZZ" Guid="ABC-ETC">
              <CreateFolder />
            </Component>
          </Directory>
        </Directory>
      </Directory>
    </DirectoryRef>

And reference the component CreateProgramDataZZZ in your feature.

It can also be helpful to set permissions on the directory like this:

<CreateFolder>
    <util:PermissionEx User="Users" GenericAll="yes" />
</CreateFolder>

(in place of <CreateFolder />)

this will create folder for you...

<Directory Id="DIR_ID" Name="DIR_NAME">
    <Component Guid="GUID" Id="id" KeyPath="no" NeverOverwrite="no" Permanent="no" Location="local">
        <CreateFolder>
            <util:PermissionEx CreateChild="yes" CreateFile="yes" Delete="yes" Read="yes" ReadAttributes="yes" ReadExtendedAttributes="yes" ReadPermission="yes" Traverse="yes" GenericRead="yes" GenericWrite="yes" User="Everyone" />
        </CreateFolder>
    </Component>
</Directory>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!