小编cwc*_*ers的帖子

.NET中的IMAPI2 MsftFileSystemImage在创建ISO时不释放文件

我成功地创建了iso映像,但是在调用此Create方法返回后,我尝试删除rootFolderPath中的文件时出现'文件正在使用'IO错误.我错过了Marshal.ReleaseComObject调用吗?

谢谢,

CW

/// <summary>
/// Create iso image from rootFolderPath and write to isoImageFilePath. Does not include the actual rootFolder itself
/// </summary>
public void Create()
{
    IFileSystemImage ifsi = new MsftFileSystemImage();
    try
    {
        ifsi.ChooseImageDefaultsForMediaType(IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DISK);
        ifsi.FileSystemsToCreate =
                FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
        ifsi.VolumeName = this.volumeName;
        ifsi.Root.AddTree(rootFolderPath, false);//use a valid folder
        //this will implement the Write method for the formatter
        IStream imagestream = ifsi.CreateResultImage().ImageStream;
        if (imagestream != null)
        {
            System.Runtime.InteropServices.ComTypes.STATSTG stat;
            imagestream.Stat(out stat, 0x01);
            IStream newStream;
            if (0 == SHCreateStreamOnFile(isoImageFilepath, 0x00001001, out …
Run Code Online (Sandbox Code Playgroud)

c# interop imapi

3
推荐指数
1
解决办法
2664
查看次数

标签 统计

c# ×1

imapi ×1

interop ×1