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

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(" 有错完成");    }
   }
  }

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值