Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!SharpCompress.Archive.Rar.RarArchive.IsRarFile(textBox1.Text))
- {
- MessageBox.Show("File is not a rar file");
- }
- else
- {
- try
- {
- String s = textBox1.Text;
- String[] fileName = Regex.Split(s, "\\\\");
- foreach (String chars in fileName)
- {
- if(chars.ToLower().Contains(".rar")){
- s = chars.ToLower().Replace(".rar",null);
- break;
- }
- }
- using (Stream stream = File.OpenRead(textBox1.Text))
- {
- var reader = ReaderFactory.Open(stream);
- while (reader.MoveToNextEntry())
- {
- String sReplaced = reader.Entry.FilePath.Replace(s, null).Replace("\\\\", null);
- Boolean bEncrypt = reader.Entry.IsEncrypted;
- String sItem = sReplaced + " Encrypted: " + bEncrypt;
- if (sReplaced != String.Empty)
- {
- listBox1.Items.Add(sItem);
- }
- for (int i = 0; i <= (listBox1.Items.Count - 1); i++)
- {
- if (listBox1.Items[i].ToString() == String.Empty)
- {
- listBox1.Items.RemoveAt(i);
- }
- }
- reader.WriteEntryToDirectory(textBox2.Text, ExtractOptions.Overwrite);
- }
- }
- }catch (Exception EX){
- MessageBox.Show(EX.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement