0

I'm trying to extract an ISO using C#, I found a Winzip library, DotNetZip, and used that but when I run the project it says that it cannot extract the ISO.

string activeDir = copyTo = this.folderBD.SelectedPath;;

folderName = toExtract.Remove(toExtract.Length - 4, 4);

Path.Combine(activeDir,  Path.GetFileNameWithoutExtension(folderName));

string zipToUnpack = toExtract;
string unpackDirectory = folderName;

using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
{
    // here, we extract every entry, but we could extract conditionally
    // based on entry name, size, date, checkbox status, etc.  
    foreach (ZipEntry file in zip1)
    {
        file.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
    }
}

That is the code I am working with. copyTo and folderName are sent in from other methods in the program.

Any libraries that let me use Winzip or Winrar on a ISO would be a great help, but so far my searches have thrown up nothing.

Thanks in advance

EDIT: Can you only extract .rar or .zip using winrar with C# or can you pass the file to be extracted as a arguement and how? I've tried

ProcessStartInfo startInfo = new ProcessStartInfo("winrar.exe"); Process.Start("winrar.exe",@"C:\file\to\be\extracted");

The ISO location, but that returns an exception that there is nothing to extract there.

ELSheepO
  • 305
  • 3
  • 9
  • 26
  • I have always been able to extract an ISO provided it was created the correct way just by extracting it. What exactly is not working and are you sure the ISO has been generated the correct way? – Security Hound May 10 '12 at 15:30
  • The ISO is generated properly i'm sure. I tried using winzip because I found a library for it so figured it was the only way but it won't let me extract an iso, only a zip – ELSheepO May 10 '12 at 15:33
  • You asked the same question [Here](http://stackoverflow.com/q/10579964/1118933) also! and [Answer is this!](http://stackoverflow.com/a/10580489/1118933) – Writwick May 15 '12 at 08:58

1 Answers1

1

You can execute winrar from c# using Process.Start and pass in the arguments you need to extract the iso.

Sean Barlow
  • 588
  • 6
  • 11
  • I don't need to import any libraries? – ELSheepO May 10 '12 at 15:32
  • 1
    @ELSheepO: no - but you have to make sure that WinRar is present on the machine where you run your code – marc_s May 10 '12 at 15:35
  • Any chance you can give me a rough code on what you used? I tried Process.Start(winrar, copyTo, foldername); But as you can propably guess it doesn't work. I'm using system.diagostics so I got that much :P – ELSheepO May 10 '12 at 15:44
  • Have winrar opening but either just goes to the c drive or no archive is found – ELSheepO May 11 '12 at 09:32