简体   繁体   中英

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 . 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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM