I am trying to extract the ISO to a folder with the same name without .iso at the end.
I had a problem with winrar since it does not start the extraction when I start a session starting from a folder with ISO.
UPDATED with response code
private void ExtractISO(string toExtract, string folderName)
{
CDReader Reader = new CDReader(File.Open(toExtract, FileMode.Open), true);
ExtractDirectory(Reader.Root, folderName + "\\", "");
Reader.Dispose();
}
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))
{
FileStr.CopyTo(Fs, 4 * 1024);
}
}
}
}
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));
}
}
The user selects the folder to extract (.ISO) to the table. Then I use it in Process.Start () in the background worker. This is similar to opening the installation software and does not extract the ISO to the desired folder name.
Thanks in advance for your help.
Or, if someone can give me a package to extract the ISO instead and call it from C # passing to Extract, and the folder name, which would also be useful.
thank
source
share