Windows Installer回滚安装目录文件清理问题 [英] Windows Installer Rollback install directory files cleanup problem

查看:302
本文介绍了Windows Installer回滚安装目录文件清理问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在使用C#.net的Windows Installer回滚功能中遇到问题
2.0.我创建了一个安装程序类,它会启动自定义操作
[安装程序类型]创建数据库并接受用户输入的应用程序
设置,如果用户想回滚,则将InstallerException与custom
一起使用 消息,但如果这样做,则在安装目录中有一些临时文件和
CreateDatabase.InstallState [CreateDatabase是我的应用程序的名称
通过自定义操作启动的文件]文件不会被删除,它们是
应该被删除.
在上述情况下,我想以系统应该
进行回滚的方式
恢复到Windows 7徽标要求的初始状态
认证.在这方面的任何帮助将不胜感激.
问候.

Hello All,

I am facing problem in Windows Installer Rollback functionality using C#.net
2.0. I have created an installer class and it launches custom action
[installer type] to create database and take user inputs for application
settings, If user wants to rollback I use InstallerException with custom
message, but if I do so then in the install directory some temp files and
CreateDatabase.InstallState [CreateDatabase is the name of my application
which is launched through custom action] file are not removed and these are
supposed to be removed.
In the mentioned scenario I want to rollback in such a way that system should
be restored to its initial state as it is requirement for Windows 7 logo
certification. Any help in this regard will be highly appreciated.
Regards.

推荐答案

如果安装出现任何问题,或者发生了卸载,则需要撤消所做的任何更改.在Rollback()和Uninstall()中,您可以访问保存在stateServer中的值. Rollback()和Uninstall()都调用我自己的新方法RemoveCustomAdditions().这将获取保存的路径字符串;如果存在,则文件将被删除.

公共重写void Rollback(IDictionary stateSaver)
{
base.Rollback(stateSaver);
RemoveCustomAdditions(stateSaver);
}
公共重写void Uninstall(IDictionary stateSaver)
{
base.Uninstall(stateSaver);
RemoveCustomAdditions(stateSaver);
}
private void RemoveCustomAdditions(IDictionary stateSaver)
{
试试
{
字符串BeginLinkPath = stateSaver ["BeginLinkPath"]作为字符串;
如果(!String.IsNullOrEmpty(BeginLinkPath))
File.Delete(BeginLinkPath);

字符串InfoLinkPath = stateSaver ["InfoLinkPath"]作为字符串;
如果(!String.IsNullOrEmpty(InfoLinkPath))
File.Delete(InfoLinkPath);
}
catch(Exception){}
}

此代码可以为您提供帮助. :)
If anything goes wrong with the install, or an uninstall occurs, you need to undo any changes you have made. In Rollback() and Uninstall() you have access to the values that were saved in stateServer. Both Rollback() and Uninstall() call my own new method RemoveCustomAdditions(). This gets the saved path strings; if they are present then the file is deleted.

public override void Rollback(IDictionary stateSaver)
{
base.Rollback(stateSaver);
RemoveCustomAdditions(stateSaver);
}
public override void Uninstall(IDictionary stateSaver)
{
base.Uninstall(stateSaver);
RemoveCustomAdditions(stateSaver);
}
private void RemoveCustomAdditions(IDictionary stateSaver)
{
try
{
string BeginLinkPath = stateSaver["BeginLinkPath"] as string;
if (!String.IsNullOrEmpty(BeginLinkPath))
File.Delete(BeginLinkPath);

string InfoLinkPath = stateSaver["InfoLinkPath"] as string;
if (!String.IsNullOrEmpty(InfoLinkPath))
File.Delete(InfoLinkPath);
}
catch (Exception ) { }
}

This code may Help you. :)


这篇关于Windows Installer回滚安装目录文件清理问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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