Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- namespace UnrarAll {
- class Program {
- const string Exec = @"C:\Program Files\7-Zip\7z.exe";
- const string Params = "e \"{0}\" -o\"{1}\" -r";
- const string initialPath = @"C:\Users\Leonardo Leal\Desktop\Puzzle\puzzle.tar.gz";
- static void Main(string[] args) {
- List<string> toDo = new List<string>() {
- initialPath
- };
- List<string> files = new List<string>();
- int count = 0;
- while(toDo.Count != 0) {
- string path = string.Format(@"{0}{1}\", AppDomain.CurrentDomain.BaseDirectory, count++);
- Directory.CreateDirectory(path);
- Process process = Process.Start(Exec, string.Format(Params, toDo[0], path));
- process.WaitForExit();
- foreach(string file in Directory.GetFiles(path)) {
- string ext = Path.GetExtension(file);
- switch(ext) {
- case ".rar":
- case ".zip":
- case ".jar":
- case ".tar":
- case ".gz":
- case ".tar.gz":
- case ".7z":
- toDo.Add(file);
- break;
- default:
- files.Add(file);
- break;
- }
- }
- toDo.RemoveAt(0);
- }
- Console.WriteLine("Done unzipping {0} files", count);
- Console.WriteLine("Files found:");
- Console.WriteLine(string.Join("\n", files));
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement