[英]Installer Custom action not working
I am trying to remove some additional files under the user profile Local Application Data folder after the uninstall of the app. 卸载应用程序后,我正在尝试删除用户配置文件“本地应用程序数据”文件夹下的一些其他文件。
i read about custom action, so i wrote this 我了解了自定义操作,所以我写了这个
namespace RemoveUserAppDataCA
{
[RunInstaller(true)]
public partial class Installer1 : System.Configuration.Install.Installer
{
public Installer1()
{
InitializeComponent();
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
// Very important! Removes all those nasty temp files.
DeleteUserDataProfile();
base.Dispose();
}
void DeleteUserDataProfile()
{
try
{
string path = Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "..\\MyCompanyFolder"));
if (Directory.Exists(path))
{
Directory.Delete(path,true);
}
}
catch (Exception)
{
throw;
}
}
}
} }
I added the dll file to the project setup , then a added a custom actions , then under the uninstall , i added the ddl file of the RemoveUserAppDataCA . 我将dll文件添加到项目设置中,然后添加了自定义操作,然后在卸载下添加了RemoveUserAppDataCA的ddl文件。 i built the system. 我建立了系统。
i did the installation , but when i uninstall the app the app folderthe user profile Local Application Data remains (does not get deleted). 我做了安装,但是当我卸载应用程序的应用程序文件夹时,用户配置文件本地应用程序数据仍然保留(不会被删除)。
What is wrong about the work ?? 工作有什么问题?
I found the problem , the folder path was wrong. 我发现了问题,文件夹路径错误。 The system was pointing at "C:\\Users\\UserName\\AppData\\App_Folder" instead of "C:\\Users\\UserName\\AppData\\Local\\App_Folder" 系统指向“ C:\\ Users \\ UserName \\ AppData \\ App_Folder”,而不是“ C:\\ Users \\ UserName \\ AppData \\ Local \\ App_Folder”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.