C # call WinRAR to realize compression and decompression

Source: Internet
Author: User
Tags rar

Using System.Diagnostics;
.............

{//************ compression *************
String strf= "Iis6.log";
String strr= "Newiis"; Compress package file name
Process P = new process ();
P.startinfo.filename= "Winrar.exe";
P.startinfo.createnowindow=false;

p.startinfo.arguments= "A-r" "+strr+" "+STRF; Default compression to RAR
p.startinfo.arguments= "A-afzip" "+strr+" "+STRF; Compress to zip
P.startinfo.arguments= "M" +strr+ "" +STRF; Compress to RAR and delete original file
p.startinfo.arguments= "a-p123456" "+strr+" "+STRF; Password is 123456

   
  {  //************ extract ************* 

//    p.startinfo.arguments= "x" +strr+ "" +strf; //from RAR uncompressed, file name to be consistent
//   p. startinfo.arguments= "x-p123456" +strr+ "" +strf; //Unzip the encrypted RAR
   
   /*     "x-o+" overwrites existing files
          "x-o-" does not overwrite existing files
          "x" + Strzippath + "  free1.txt" ' + strtxtpath  extract fr only from compressed package Ee1.txt, other files are not uncompressed
          "-y"    response to all inquiries is "yes", that is, errors do not pop-up windows
           "-CL"    Convert file name is lowercase     * */

   p.start ();
   if p.hasexited
   {
    int iExitCode = P.ExitCode;
    if (iexitcode = 0)
    {      MessageBox.Show ("normal completion");     }
    else
    {      messagebox.show ("error Complete");     }
   
    

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.