Esempio n. 1
0
 public bool extractRar(string archiveName, ProgressBar progress, Label status, bool singleFile = false)
 {
     attachedProgressBar = progress;
     attachedStatus      = status;
     if (singleFile && (fileInRar == ""))
     {
         return(false);
     }
     this.unrar = new Unrar();
     this.AttachHandlers(this.unrar);
     for (int i = 0; i < outFileSet.Length; i++)
     {
         if (outFileSet.Substring((outFileSet.Length - 1) - i, 1) == "/")
         {
             outFileSet = outFileSet.Substring(0, outFileSet.Length - i);
             break;
         }
     }
     this.unrar.DestinationPath = outFileSet;
     this.unrar.Open(archiveName, Unrar.OpenMode.Extract);
     while (this.unrar.ReadHeader())
     {
         if (!singleFile)
         {
             fileInRar = this.unrar.CurrentFile.FileName;
         }
         if (this.unrar.CurrentFile.FileName == fileInRar)
         {
             progress.Maximum = 100;
             progress.Value   = 0;
             status.Text      = "Extracting File 0%";
             Application.DoEvents();
             this.unrar.Extract();
         }
         else
         {
             this.unrar.Skip();
         }
     }
     this.unrar.Close();
     status.Text      = "Extracting File Complete";
     progress.Maximum = 4;
     progress.Value   = 4;
     Application.DoEvents();
     return(true);
 }
Esempio n. 2
0
 private void AttachHandlers(Unrar unrar)
 {
     unrar.ExtractionProgress += new ExtractionProgressHandler(this.unrar_ExtractionProgress);
     unrar.MissingVolume      += new MissingVolumeHandler(this.unrar_MissingVolume);
     unrar.PasswordRequired   += new PasswordRequiredHandler(this.unrar_PasswordRequired);
 }