Create a folder in disk and Burn Into it using IMAPI 2

余生长醉 提交于 2019-12-11 23:25:29

问题


I'm using IMAPI2 in C# to burn a list of files to a multisession disk. But I want To be able to burn those files into a directory in the disk. Right now this is what I have

fileSystemImage = new MsftFileSystemImage();
            fileSystemImage.ChooseImageDefaults(discRecorder);
            fileSystemImage.FileSystemsToCreate =
            FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
if (multisessionInterfaces != null)
            {
                fileSystemImage.MultisessionInterfaces = multisessionInterfaces;
                fileSystemImage.ImportFileSystem();
            }
IFsiDirectoryItem rootItem = fileSystemImage.Root;
rootItem.AddTree(sourceDirectory,includeBaseDirectory)

This is a round about method because I have to create a temporary folder in my drive and copy all the files I want to burn into that folder and add that folder as the burn item.

I'm Using a slightly modified version of this C# IMAPI2 wrapper to implement this http://www.codeproject.com/Articles/24544/Burning-and-Erasing-CD-DVD-Blu-ray-Media-with-C-an


回答1:


you can use the method IFsiDirectoryItem::AddDirectory of the IFsiDirectoryItem interface to add a directory to the file system image on the optical media; and after that, retrieve it with IFsiDirectoryItem::get_Item method.

For example: Instead of

rootItem.AddTree(sourceDirectory,includeBaseDirectory);

Replace with something like:

rootItem.AddDirectory(directoryName);
rootItem.get_Item(directoryName, newDirItem);   

You can create multiple directory levels (just call AddDirectory on the appropriate directory item instead of rootItem).

Also, you may want to reuse existing directories on optical media if the directories already exist. You can do that by taking into account the error IMAPI_E_DUP_NAME ((HRESULT)0xC0AAB112L) returned when trying to get the directory...



来源:https://stackoverflow.com/questions/18634981/create-a-folder-in-disk-and-burn-into-it-using-imapi-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!