Unable To Extract Windows 11 Iso

Joined
Feb 9, 2023
Messages
16
Programming Experience
10+
good morning all,

i been trying for a while to get this code to extract windows 11 iso but just wont give me the path I need
I have tried to get the info from the DiscDirectoryInfo but don't get a full name or name or path

so trying to extract it is difficult

windows 11 iso.png


but I have tyied multiple ways round including trying to automate winrar to do it it does extract manually but just cant get it to find the correct info ant help would be much appreciated as I totally lost on how to extract this iso

thank you in advance elfenliedtopfan5
 
Please always post code as text, formatted as code. You can provide a screenshot as well, if it adds value, but always post the code as text. Same goes for error messages and the like.
 
Also, if you do post a screenshot, please only post what is actually necessary. Given that Windows has tools to capture an arbitrary area, there's no need to capture the entire screen. If you do capture the whole screen anyway, please crop it before posting.
 
I don't see what the problem is. Reader.Root seem to be correctly giving the Name and FullName of the root of the ISO image which is the empty string and "\" respectively. What were you expecting to see?
 
I don't see what the problem is. Reader.Root seem to be correctly giving the Name and FullName of the root of the ISO image which is the empty string and "\" respectively. What were you expecting to see?

well the issue i have is when it hits the extractDirectory


C#:
        private void ExtractISO(string isopath, string folderName)
        {
            // reads the ISO
            CDReader Reader = new CDReader(File.Open(isopath, FileMode.Open), true);
            // passes the root directory the folder name and the folder to extract
            ExtractDirectory(Reader.Root, folderName /*+ Path.GetFileNameWithoutExtension(toExtract)*/ + "\\", "");
            // clears reader and frees memory
            Reader.Dispose();
        }

it will go to here

C#:
private 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)) // 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));
    }
}

when it hits here it will skip it as it returns false and then go to root path
and when it hits the foreach statements to get the get directories it returns nothing same with get files and does not extract anything

basically what I am expecting it to do is get the iso path that it does and get the files in the windows 11 iso and extract to a folder so I can edit them
tried the mounting way but its protected and wont let me exract the install.esd so I want to exract the iso make changes then rebuild it but unable to get it to extract as it cant seem to find the structure of it

the structure of the so is

Screenshot 2024-01-22 181702.png
 
Last edited by a moderator:
Anyway of course these lines will be skipped:
C#:
if (!string.IsNullOrWhiteSpace(PathinISO))
{
    PathinISO += "\\" + Dinfo.Name;
}
because you passed in an empty string for the PathinISO parameter (e.g. the last parameter) here:
C#:
ExtractDirectory(Reader.Root, folderName /*+ Path.GetFileNameWithoutExtension(toExtract)*/ + "\\", "");

Additionally, in all your recursive call to ExtractDirectory you don't bother computing a new path, so you continue to pass an empty string:
C#:
ExtractDirectory(dinfo, RootPath, PathinISO);


As for your issue that none of the foreach loops seem to be doing anything, I don't really know how to help you. I'm not familiar with the working for whatever that DiscDirectoryInfo class. I presume that is something your got from whatever library that is also providing the CDReader class. You'll likely get better help from that supports that library with regards to the behavior of those classes and methods.
 

Latest posts

Back
Top Bottom