在安装文件中解压sfx压缩文件

利用winrar可以制作自解压文件(sfx)
"C:\Program Files\WinRAR\WinRAR.exe" a -r -y -sfx -ep1 -zHostCheck.diz -x*\.svn\* HostCheck.exe HostCheck\*
其中HostChek.diz的内容如下:
Title=解压文件
Text
{
安装程序正在解压文件,这可能需要几分钟的时间
请稍候...
}
Path=.\HostCheck
overwrite=2
Silent=2

在安装程序的install方法中,可以调用UnRarFiles方法将压缩包解压到安装目录。
注意:解压时,要现将当前目录设置为安装目录,否则压缩文件将被解压到system32下
None.gif public   void  UnRarFiles()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
string InstallDir=this.Context.Parameters["targetdir"];
InBlock.gif            
string CurrentDir=Directory.GetCurrentDirectory();
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Directory.SetCurrentDirectory(InstallDir);    
InBlock.gif                //FileAppend(
"install","in directory "+Directory.GetCurrentDirectory());
InBlock.gif                Process.Start(InstallDir
+"\\HostCheck.exe");
InBlock.gif                Directory.SetCurrentDirectory(CurrentDir);
InBlock.gif                //FileAppend(
"install","in directory "+Directory.GetCurrentDirectory());
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                FileAppend(
"install","UarFiles erro:"+ex.Message);
InBlock.gif                
return;
ExpandedSubBlockEnd.gif            }

ExpandedBlockEnd.gif        }

   

转载于:https://www.cnblogs.com/Donal/archive/2006/04/05/367175.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值