Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have found the following code from the internet after a long day of searching and its working though its not producing full file names and extensions of the files and folders in the iso image. It is truncating the file and folder names to produce a maximun of 8 character name as well as 3 character file extensions/ This means that all filenames longer than * characters will not be written correctly and all other file extensions with ,more than 3 characters will not be written correctly as well. thank you for reading. I really need your help.

C#
ExtractISO(string ISOName, string ExtractionPath)
{
    using (FileStream ISOStream = File.Open(ISOName, FileMode.Open))
    {
        CDReader Reader = new CDReader(ISOStream, true, true);
                ExtractDirectory(Reader.Root, ExtractionPath + Path.GetFileNameWithoutExtension(ISOName) + "\\", "");
                Reader.Dispose();
    }
}

void ExtractDirectory(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO)
{
    if (!string.IsNullOrWhiteSpace(PathinISO))
    {
        PathinISO += "\\" + Dinfo.Name;
    }
    RootPath += "\\" + Dinfo.Name;
    AppendDirectory(RootPath);
    foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
    {
        ExtractDirectory(dinfo, RootPath, PathinISO);
    }
    foreach (DiscFileInfo finfo in Dinfo.GetFiles())
    {
        using (Stream FileStr = finfo.OpenRead())
        {
            using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name, 4 * 1024)) // Here you can Set the BufferSize Also e.g. File.Create(RootPath + "\\" + finfo.Name, 4 * 1024)
            {
                FileStr.CopyTo(Fs, 4 * 1024); // Buffer Size is 4 * 1024 but you can modify it in your code as per your need
            }
        }
    }
}
static void AppendDirectory(string path)
{
    try
    {
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
    }
    catch (DirectoryNotFoundException Ex)
    {
        AppendDirectory(Path.GetDirectoryName(path));
    }
    catch (PathTooLongException Ex)
    {
        AppendDirectory(Path.GetDirectoryName(path));
    }
}

private void btnExtractIso_Click(object sender, EventArgs e)
{
  ExtractISO("C:\\Users\\tjdtud\\Desktop\\done\\publish.iso", "C:\\Users\\tjdtud\\Desktop\\extracted\\");
}



code taken from this article href="http://stackoverflow.com/questions/10579964/extract-iso-with-winrar-automatically-with-c-sharp-or-batch

Thank you for the so much needed help
Posted
Updated 28-Apr-15 3:31am
v2
Comments
Richard MacCutchan 28-Apr-15 9:31am    
Don't you think you should be asking the person at SO who wrote this code?

1 solution

I can suggest you one alternative: famous open-source 7zip:
http://en.wikipedia.org/wiki/7-Zip[^],
http://www.7-zip.org/[^].

It certainly can extract from ISO images; I use it on regular basis.

If you don't want to just do it through 7zip.exe started using System.Diagnostics.Process.Start, you can use .NET API for 7-zip: http://sevenzipsharp.codeplex.com/[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900