问题描述
安装后,我在文件夹 C:Program Files (x86)
中有以下文件夹结构:
After an installation, I have the following folder structure in the folder C:Program Files (x86)
:
generated
文件夹的路径是:C:Program Files (x86)CompanyNameAppNamegenerated
文件夹 generated
包含应用程序在运行时通过 C# 代码创建的子文件夹和文件:
The folder generated
contains subfolders and files they will be created by the application during the runtime via C# code:
var lPathToDir = Path.Combine(lFileService.GetFilePath, pSamAccountName);
if (!Directory.Exists(lPathToDir))
{
Directory.CreateDirectory(lPathToDir);
}
变量 lPathToDir
可以有以下值:
The variable lPathToDir
could have the values:
C:Program Files (x86)CompanyNameAppNamegenerateduser1
// or
C:Program Files (x86)CompanyNameAppNamegenerateduser2
然后看起来像:
我的问题:卸载后,这些子文件夹 user1
、user2
不会被删除.我使用以下 Wix 声明:
My Problem: After an uninstall, these subfolders user1
, user2
will not be removed. I use the following Wix declaration:
<!-- Target installation folder -->
<Directory Id="ProgramFilesFolder" Name="$(var.ProgramFilesFolder)">
<Directory Id="APPLICATIONFOLDER" Name="$(var.AppFolderName)">
<Directory Id="BIN" Name="bin" />
<Directory Id="HELP" Name="help" />
<Directory Id="GENERATED" Name="generated" />
<Component Id="RemoveAll" Guid="THE-GUID-HERE">
<RemoveFile Id="RemoveAllFilesOnUninstall" Directory="APPLICATIONFOLDER" Name="*.*" On="uninstall" />
<RemoveFolder Id="RemoveAllFoldersOnUninstall" Directory="APPLICATIONFOLDER" On="uninstall" />
<util:RemoveFolderEx On="uninstall" Property="GENERATED" />
</Component>
</Directory>
</Directory>
卸载后:
为什么这些文件夹会保留,我该如何从安装文件夹中删除这些生成的文件夹?当我通过 C# 创建这些文件夹时,也许我需要设置任何权限?
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#?
推荐答案
现在与 Bob Arnson 建议的 RemoveFolderEx
一起使用.但是除了声明 <util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER"/>
还有一些注册表声明是必要的:
Works now with RemoveFolderEx
as suggested by Bob Arnson. But in addition to the declaration <util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
there are also some registry declarations necessary:
<!-- add this: -->
<Property Id="APPLICATIONFOLDER">
<RegistrySearch Key="SOFTWARE$(var.Manufacturer)$(var.AppName)" Root="HKLM" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
</Property>
<Directory Id="BIN" Name="bin" />
<Directory Id="HELP" Name="help" />
<Directory Id="GENERATED" Name="generated" />
<Component Id="RemoveAll" Guid="THE-GUID-HERE">
<RemoveFile Id="RemoveAllFilesOnUninstall" Directory="APPLICATIONFOLDER" Name="*.*" On="uninstall" />
<RemoveFolder Id="RemoveAllFoldersOnUninstall" Directory="APPLICATIONFOLDER" On="uninstall" />
<!-- add this: -->
<RegistryValue Root="HKLM" Key="SOFTWARE$(var.Manufacturer)$(var.AppName)" Name="Path" Type="string" Value="[APPLICATIONFOLDER]" KeyPath="yes" />
<util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
</Component>
</Directory>
这篇关于如何在卸载时通过 Wix 删除生成的文件夹和文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!