title: How can I delete generated folders and files via Wix on uninstall?
body: <p>After an installation, I have the following folder structure in the folder <code>C:\Program Files (x86)</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/1L4r4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1L4r4.png" alt="Folder Structure after install"></a></p>
  
  <p>The Path to the folder <code>generated</code> is: <code>C:\Program Files (x86)\CompanyName\AppName\generated</code></p>
  
  <p>The folder <code>generated</code> contains subfolders and files they will be created by the application during the runtime via C# code:</p>
  
  <pre><code>var lPathToDir = Path.Combine(lFileService.GetFilePath, pSamAccountName);
  
  if (!Directory.Exists(lPathToDir))
  {
      Directory.CreateDirectory(lPathToDir);
  }
  </code></pre>
  
  <p>The variable <code>lPathToDir</code> could have the values: </p>
  
  <pre><code>C:\Program Files (x86)\CompanyName\AppName\generated\user1
  // or
  C:\Program Files (x86)\CompanyName\AppName\generated\user2
  </code></pre>
  
  <p>Then it looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/AMqo9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AMqo9.png" alt="enter image description here"></a></p>
  
  <p><strong>My Problem:</strong> After an uninstall, these subfolders <code>user1</code>, <code>user2</code> will not be removed. I use the following Wix declaration:</p>
  
  <pre><code>&lt;!-- Target installation folder --&gt;
  &lt;Directory Id="ProgramFilesFolder" Name="$(var.ProgramFilesFolder)"&gt;
      &lt;Directory Id="APPLICATIONFOLDER" Name="$(var.AppFolderName)"&gt;
  
        &lt;Directory Id="BIN" Name="bin" /&gt;
        &lt;Directory Id="HELP" Name="help" /&gt;
        &lt;Directory Id="GENERATED" Name="generated" /&gt;
  
        &lt;Component Id="RemoveAll" Guid="THE-GUID-HERE"&gt;
          &lt;RemoveFile Id="RemoveAllFilesOnUninstall" Directory="APPLICATIONFOLDER" Name="*.*" On="uninstall" /&gt;
          &lt;RemoveFolder Id="RemoveAllFoldersOnUninstall" Directory="APPLICATIONFOLDER" On="uninstall" /&gt;
          &lt;util:RemoveFolderEx On="uninstall" Property="GENERATED" /&gt;
        &lt;/Component&gt;
  
      &lt;/Directory&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>After uninstall:</p>
  
  <p><a href="https://i.stack.imgur.com/8WFBo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8WFBo.png" alt="enter image description here"></a></p>
  
  <p>Why do these folders stay and how can I remove these generated folders from the installation folder? Perhaps do I need to set any permissions when I create these folders via C#?</p>