来自C#-.NET DiscUtils的DVD ISO替代方案
基于C#的文件夹结构制作.ISO文件的最佳方法是什么?除此之外还有开源库吗?遇到与讨论有关的问题,我想尝试另一种方法。我有什么选择?我更喜欢开源,但也可能愿意为解决方案付费。这里还有一些可以尝试的来自C#-.NET DiscUtils的DVD ISO替代方案,c#,.net,dvd,iso9660,C#,.net,Dvd,Iso9660,基于C#的文件夹结构制作.ISO文件的最佳方法是什么?除此之外还有开源库吗?遇到与讨论有关的问题,我想尝试另一种方法。我有什么选择?我更喜欢开源,但也可能愿意为解决方案付费。这里还有一些可以尝试的 (不支持音频CD) 您可以尝试Primo Burner:Windows实际上提供了一个用于创建ISOs的本机API,以及更多内容:应用程序。从Windows SDK或(可能更容易)中获取IMAPI2互操作程序集后,创建ISO只需几行代码 不幸的是,您还需要一些段落来正确地清理涉及的COM废话,但最
- (不支持音频CD)
MsftFileSystemImage iso = new MsftFileSystemImage();
iso.ChooseImageDefaultsForMediaType(IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DISK);
iso.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660 | FsiFileSystems.FsiFileSystemJoliet;
iso.Root.AddTree(@"c:\path\goes\here\", false);
dynamic resultImage = iso.CreateResultImage();
dynamic imageStream = resultImage.ImageStream;
IStream newStream = null;
if (imageStream != null)
{
STATSTG stat = null;
imageStream.Stat(stat, 0x1);
int res = SHCreateStreamOnFile(@"c:\path\to\your.iso", 0x1001, newStream);
if (res == 0 && newStream != null)
{
IntPtr inBytes = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(long)));
IntPtr outBytes = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(long)));
try
{
imageStream.CopyTo(newStream, stat.cbSize, inBytes, outBytes);
}
finally
{
Marshal.FinalReleaseComObject(imageStream);
newStream.Commit(0);
Marshal.FinalReleaseComObject(newStream);
Marshal.FreeHGlobal(inBytes);
Marshal.FreeHGlobal(outBytes);
Marshal.FinalReleaseComObject(resultImage);
Marshal.FinalReleaseComObject(iso);
}
}
else
{
Marshal.FinalReleaseComObject(imageStream);
Marshal.FinalReleaseComObject(resultImage);
Marshal.FinalReleaseComObject(iso);
//TODO: Throw exception or do whatever to signal failure here
}
}
else
{
Marshal.FinalReleaseComObject(resultImage);
Marshal.FinalReleaseComObject(iso);
//TODO: Throw exception or do whatever to signal failure here
}
有关使用的Win32/COM API胶水的唯一部分的详细信息,请访问pinvoke.net:。IStream和STATSTG正在考虑使用DiscUtils来满足当前的项目需求……您遇到了哪些具体问题?这里的代码似乎没有按编写的那样工作;类型和函数参数存在多个问题。该示例还应使用语句和所需的P/Invoke声明显示适当的
。此外,调用Marshal.finalEleaseComObject
也不是必需的(事实上可能是不好的)。运行时自动处理引用。