Create ISO image using PowerShell: how to save IStream to file?

前端 未结 2 1179
既然无缘
既然无缘 2020-12-19 04:47

I want to create an ISO image, so a .iso file, on Windows. This is possible to do using COM component IMAPI2FS.MsftFileSystemImage, and I found instructions on how to do th

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-19 05:00

    You can use the DiscUtils library to make ISOs (and manage other disk formats such as VHD/VHDX, DMG, FAT, etc). A PowerShell module is supported as well an MSBUILD task to automatically create your ISO on project build.

    Create a CDBuilder object and go to town with adding files and directories then save it to disk with the Build method. Download documentation here.

     CDBuilder builder = new CDBuilder();
     builder.AddFile("samplefile.txt", new byte[] { });
     builder.Build(@"c:\output.iso");
    

    The great thing about this approach is that it is 100% managed code and cross-platform - there is no IMAPI2 COM/Marshaling requirement.

提交回复
热议问题