如何在C#中解压缩Iso映像 [英] How Do I Unzip An Iso Image Using In C#

查看:269
本文介绍了如何在C#中解压缩Iso映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过漫长的一天搜索,我发现了以下代码,虽然它没有生成ISO映像中文件和文件夹的完整文件名和扩展名,但仍在工作。它正在截断文件和文件夹名称以产生8个字符名称的最大值以及3个字符的文件扩展名/这意味着所有长于*字符的文件名将无法正确写入,所有其他文件扩展名将超过3个字符将也不能正确书写。谢谢你的阅读。我真的需要你的帮助。



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.

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\\");
}







来自本文的代码href =http:// stackoverflow。 com / questions / 10579964 / extract-iso-with-winrar-automatic-with-c-sharp-or-batch



感谢您提供所需的帮助




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

推荐答案

我可以建议你一个替代方案:着名的开源7zip:

http://en.wikipedia.org/wiki/7-Zip [ ^ ],

http:// www.7-zip.org/ [ ^ ]。



它当然可以从ISO图像中提取;我经常使用它。



如果你不喜欢我想通过使用 System.Diagnostics.Process.Start 开始的7zip.exe来实现,你可以使用.NET API进行7-zip:http://se venzipsharp.codeplex.com/ [ ^ ]。



-SA
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


这篇关于如何在C#中解压缩Iso映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆