您的位置:首页 > 编程语言 > C#

C#调用WinRAR实现压缩与解压缩

2007-07-03 10:36 716 查看
using System.Diagnostics;
.............

{ //************ 压 缩 *************
string strF="iis6.log";
string strR="newiis"; //压缩包文件名
Process p = new Process();
p.StartInfo.FileName="Winrar.exe";
p.StartInfo.CreateNoWindow=false;

// p.StartInfo.Arguments=" a -r "+strR+" "+strF; //默认压缩到RAR
// p.StartInfo.Arguments=" a -afzip "+strR+" "+strF; //压缩到Zip
// p.StartInfo.Arguments=" m "+strR+" "+strF; //压缩到RAR并删除原文件
// p.StartInfo.Arguments=" a -p123456 "+strR+" "+strF; //密码为123456

{ //************ 解 压 缩 *************

// p.StartInfo.Arguments=" x "+strR+" "+strF; //从RAR解压缩,文件名要一致
// p.StartInfo.Arguments=" x -p123456 "+strR+" "+strF; //解压加密的RAR

/* " x -o+" 覆盖已经存在的文件
" x -o-" 不覆盖已经存在的文件
" x " + strzipPath + " free1.txt "' + strtxtPath 只从压缩包中解压出free1.txt,其它文件不予解压
" -y" 对所有询问回应为"是",即发生错误也不弹出窗口
" -cl" 转换文件名为小写字母 */

p.Start();
if p.HasExited
{
int iExitCode = p.ExitCode;
if (iExitCode == 0)
{ MessageBox.Show( "正常完成"); }
else
{ MessageBox.Show(" 有错完成"); }
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: