运行卸载应用程序 [英] run an uninstall of application

查看:110
本文介绍了运行卸载应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在每个上面运行一个卸载程序(通过重用现有的上诉解雇!)。

这个我已经完成的代码,但我不认为它能满足我的需要



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

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");
            }
        }
    }

推荐答案

否......这不是正确的方法这样做(尽管您可以删除应用程序的所有文件以将其从客户端的计算机中删除)但您应该尝试使用 安装程序 [ ^ ]类 System.Configration.Install 命名空间。它允许您具有安装和卸载应用程序的功能。



您可以运行Install()函数来运行安装,然后您可以运行Uninstall功能从客户端的机器中删除文件。如果您转到安装程序MSDN文档(我已附加),您也会找到一个示例。然后,您可以提供要保存的文件以及用户触发这两个功能时要删除的文件。有关此过程的更多信息,请阅读文档。
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.


这篇关于运行卸载应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆