public void ConvertToImage(string rarPath, string imageOutputDirPath) { try { Unrar tmp = new Unrar(rarPath); tmp.Open(Unrar.OpenMode.List); string[] files = tmp.ListFiles(); tmp.Close(); int total = files.Length; int done = 0; Unrar unrar = new Unrar(rarPath); unrar.Open(Unrar.OpenMode.Extract); unrar.DestinationPath = imageOutputDirPath; while (unrar.ReadHeader() && !cancelled) { if (unrar.CurrentFile.IsDirectory) { unrar.Skip(); } else { unrar.Extract(); ++done; if (this.ProgressChanged != null) { this.ProgressChanged(done, total); } } } unrar.Close(); if (this.ConvertSucceed != null) { this.ConvertSucceed(); } } catch (Exception ex) { if (this.ConvertFailed != null) { this.ConvertFailed(ex.Message); } } }