标题:如何调用RAR生成exe自解压文件
只看楼主
CrazyChild
Rank: 1
来 自:广东汕头
等 级:新手上路
帖 子:21
专家分:2
注 册:2010-12-31
结帖率:100%
 问题点数:0 回复次数:1 
如何调用RAR生成exe自解压文件
如何调用RAR生成EXE自解压文件,要设置密码,使用最好的压缩方式,固实压缩文件,锁定压缩文件,从文件读取注释添加到RAR中.
搜索更多相关主题的帖子: 设置密码 压缩文件 
2011-04-13 15:20
xydddaxia
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:33
帖 子:466
专家分:2307
注 册:2009-3-20
得分:0 
可以带命令符运行压缩软件rar.exe主程序来实现,比如解压 "x 压缩包 目标位置 -y"
/// <summary>
        /// 解压缩
        /// </summary>
        /// <param name="unRarPatch">解压</param>
        /// <param name="rarName"></param>
        /// <returns></returns>
        public string unCompressRAR(string unRarPatch, string rarName)
        {
            string the_rar;
            RegistryKey the_Reg;
            object the_Obj;
            string the_Info;
            try
            {
                the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
                the_Obj = the_Reg.GetValue("");
                the_rar = the_Obj.ToString();
                the_Reg.Close();
                //the_rar = the_rar.Substring(1, the_rar.Length - 7);
                if (Directory.Exists(unRarPatch) == false)
                {
                    Directory.CreateDirectory(unRarPatch);
                }
                the_Info = "x " + rarName + " " + unRarPatch + " -y";
                ProcessStartInfo the_StartInfo = new ProcessStartInfo();
                the_StartInfo.FileName = the_rar;
                the_StartInfo.Arguments = the_Info;
                the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                the_StartInfo.WorkingDirectory = unRarPatch;//获取压缩包路径
                Process the_Process = new Process();
                the_Process.StartInfo = the_StartInfo;
                try
                {
                    the_Process.Start();
                    the_Process.WaitForExit();
                    the_Process.Close();
                }
                catch
                {
                }
            }
        }


站在春哥的肩膀上
2011-04-15 13:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-336531-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.086149 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved