Click here to Skip to main content
15,917,177 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Run an uninstaller on each (by reusing the existing appeal dismissal!).
this the code that i have done but i don"t think that it does what i need

C#
public virtual void UninstallAll(IDictionary savedState)
        {
            //récupération des seaID

            List<int> returnList = new List<int>();

            Log.info("[SEAIDLIST] [GETSEAIDSINSAFE]");

            string path = System.Reflection.Assembly.GetEntryAssembly().Location;
            path = path.Substring(0, path.LastIndexOf("\\")) + "\\safe\\";

            if (Directory.Exists(path))
            {
                Log.info("[SEAIDLIST] [GETSEAIDSINSAFE] Safe exist");

                String[] fileNames = Directory.GetFiles(path);

                foreach (String fileName in fileNames)
                {
                    String fileNameTrucate = fileName.Substring(fileName.LastIndexOf("\\") + 1);

                    int seaId;

                    if (Int32.TryParse(fileNameTrucate, out seaId))
                    {
                        Log.info("[SEAIDLIST] [GETSEAIDSINSAFE] SeaId: " + seaId);

                        returnList.Add(seaId);
                    }
                }
            }
            else
            {
                Log.info("[SEAIDLIST] [GETSEAIDSINSAFE] Client never launched");
            }

            return returnList;

            if (returnList == null)
            {
                Console.WriteLine("Uninstallation Error !");
            }
            else
            {
                base.Uninstall(returnList);
                Console.WriteLine("The Uninstall method of 'MyInstallerSample' has been called");
            }
        }
    }
Posted

1 solution

No... This is not the right way to do it (although you can delete all of the files of your application to remove it from client's machine but) you should try using the Installer[^] class of System.Configration.Install namespace. It allows you to have a function to Install and Uninstall the application.

You can run the Install() function to run the installation, and then you can run the Uninstall function to delete the files from client's machine. If you go to the Installer MSDN document (I have attached) you will find an example of this also. Then you can provide the files to save and also files to remove when user triggers both of the functions. Read the documentation for more on this procedure.
 
Share this answer
 
Comments
Member 11484624 30-Apr-15 3:35am    
ok thx :)
Afzaal Ahmad Zeeshan 30-Apr-15 5:34am    
You can also mark this as selected answer as a thank you. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900