I have attached the code I am using below. But during the [ iFileSystemImage.MultisessionInterfaces = iDiscFormat2Data.MultisessionInterfaces;] statement the code throws exception [Interface not supported]. Other properties also throw the same error during the [set].
public MediaInformation DetectMedia(IDiscRecorder2 discRecorder)
{
MsftFileSystemImage fileSystemImage = new MsftFileSystemImage();
MsftDiscFormat2Data discFormatData = new MsftDiscFormat2Data();
try
{
var iFileSystemImage = fileSystemImage as IFileSystemImage;
var iDiscFormat2Data = discFormatData as IDiscFormat2Data;
if (iFileSystemImage == null)
{
Console.WriteLine($"Could not cast to IFileSystemImage");
return null;
}
if (iDiscFormat2Data == null)
{
Console.WriteLine($"Could not cast to IDiscFormat2Data");
return null;
}
if (!iDiscFormat2Data.IsCurrentMediaSupported(discRecorder))
{
Console.WriteLine("Current media is not supported");
return null;
}
var mediaInformation = new MediaInformation();
// Get the media type in the recorder
iDiscFormat2Data.Recorder = discRecorder;
var mediaType = (iDiscFormat2Data).CurrentPhysicalMediaType;
var mediaTypeString = GetMediaTypeString(mediaType);
mediaInformation.MediaType = mediaTypeString;
Console.WriteLine($"Media Type : 「{mediaTypeString}」");
// Create a file system and select media type
iFileSystemImage.ChooseImageDefaultsForMediaType(mediaType);
// See if there are other recored sessions on the disc
if (!iDiscFormat2Data.MediaHeuristicallyBlank)
{
iFileSystemImage.MultisessionInterfaces = iDiscFormat2Data.MultisessionInterfaces;
iFileSystemImage.ImportFileSystem();
}
var fileMediaBlocks = iFileSystemImage.FreeMediaBlocks;
var totalDiskSize = 2048 * fileMediaBlocks;
mediaInformation.TotalDiskSize = totalDiskSize;
Console.WriteLine($"Total Disk Size : 「{totalDiskSize}」");
return mediaInformation;
}
catch (Exception ex)
{
Console.WriteLine(ex);
return null;
}
finally
{
if (fileSystemImage != null)
{
Marshal.ReleaseComObject(fileSystemImage);
}
if (discFormatData != null)
{
Marshal.ReleaseComObject(discFormatData);
}
}
}
I have attached the code I am using below. But during the [ iFileSystemImage.MultisessionInterfaces = iDiscFormat2Data.MultisessionInterfaces;] statement the code throws exception [Interface not supported]. Other properties also throw the same error during the [set].