Nihal Ahmed

Nihal Ahmed

  • 1.6k
  • 96
  • 20.6k

Working With Disc Brunning Using IMapi.

Feb 11 2014 2:35 AM
ello all,
I am on a stage where i need to write a folder in disc and add some files in that folder from my local drive and so on,
it is ok to make a folder in disc even ok to write files in disc as bulk data But i am having problem in writing data in perticular Directory in Disc,
Here is the Code
[CODE]
public void BurnDirectory(IDiscRecorder2 recorder, List<String> Images, List<String> Videos,String DiscLabel)
{
try
{
IDiscFormat2Data dataWriterImage = new MsftDiscFormat2Data();
dataWriterImage.Recorder = recorder;
if (!dataWriterImage.IsRecorderSupported(recorder))
{
Console.WriteLine("The recorder is not supported");
return;
}
if (!dataWriterImage.IsCurrentMediaSupported(recorder))
{
Console.WriteLine("The current media is not supported");
return;
}
dataWriterImage.ClientName = "My Disc";
IFileSystemImage fsi = new MsftFileSystemImage();
// Set the media size
fsi.FreeMediaBlocks = dataWriterImage.FreeSectorsOnMedia;
if (DiscLabel != "")
{
fsi.VolumeName = DiscLabel;
}
fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660;
IFsiDirectoryItem ImageDir = fsi.Root;
Boolean Flag = true;
for (int i = 0; i < Images.Count; i++)
{
if (Flag)
{
//ImageDir = fsi.CreateDirectoryItem("Images");
ImageDir.AddDirectory("Images");
//ImageDir.AddDirectory("Images");
Flag = false;
}
ImageDir.AddTree(Images[i], false);
}
IFsiDirectoryItem VideoDir = fsi.Root;
Flag = true;
for (int i = 0; i < Videos.Count; i++)
{
if (Flag)
{
VideoDir.AddDirectory("Videos");
Flag = false;
}
VideoDir.AddTree(Videos[i], false);
}
IFileSystemImageResult result = fsi.CreateResultImage();
IStream stream = result.ImageStream;
DiscFormat2Data_Events progress = dataWriterImage as DiscFormat2Data_Events;
progress.Update += new DiscFormat2Data_EventsHandler(DiscFormat2Data_ProgressUpdate);
dataWriterImage.ForceOverwrite = true;
dataWriterImage.Write(stream); // Burn the stream to disc
progress.Update -= new DiscFormat2Data_EventsHandler(DiscFormat2Data_ProgressUpdate);
}
catch (Exception ex)
{
throw (ex);
}
}
[/CODE]
In short, I need to add some folder lets say images and add some files in it.
Please Help me