Burning folders with there files using NeroCom + C#

vbimport

#1

hi everybody

I need to burn folders that contain files (and may be sub folders too).
how can i do such a think (i want to see the folder in cd and not only files)? :confused:

I wrote the following code (for folder that contains only files):

private void nDrive_OnDoneImport(ref bool Ok, ref NeroFolder Folder, ref NeroCDStamp CDStamp)
{
Console.WriteLine("nDrive_OnDoneImport: ");
folderClass = (NeroFolderClass)Folder;
myResetEvent.Set();
}

void burn()
{

string []sBackupFajli;
NeroISOTrackClass ISOTrack = new NeroISOTrackClass();



drive.OnDoneImport += new _INeroDriveEvents_OnDoneImportEventHandler(nDrive_OnDoneImport);

drive.ImportIsoTrack((int)mediaInf.NumOfUsedTrucks + 1, NERO_IMPORT_ISO_TRACK_FLAGS.NERO_IMPORT_ISO_ONLY);

sBackupFajli = Directory.GetFiles(@“D:\c-sharp\BOOK”);

ISOTrack.RootFolder = folderClass;
ISOTrack.Name = “Test”;

for(int i=0;i<sBackupFajli.Length;i++)
{
NeroFileClass nFile = new NeroFileClass();
nFile.SourceFilePath=sBackupFajli[i];
nFile.Name=sBackupFajli[i].Substring(sBackupFajli[i].LastIndexOf("\")+1);
folderClass.Files.Add(nFile);
}

// exec

isoTrack.BurnOptions = (NEROLib.NERO_BURN_OPTIONS)((int)NEROLib.NERO_BURN_OPTIONS.NERO_BURN_OPTION_CREATE_ISO_FS +
(int)NEROLib.NERO_BURN_OPTIONS.NERO_BURN_OPTION_USE_JOLIET);

drive.BurnIsoAudioCD("", “”, false, ISOTrack, null, null, NEROLib.NERO_BURN_FLAGS.NERO_BURN_FLAG_WRITE, 3, NEROLib.NERO_MEDIA_TYPE.NERO_MEDIA_CD);
}

whatever happen is that all the files in “D:\c-sharp\BOOK” become burn into CD but not in “BOOK” folder.

thanks


#2

If you wont to have folders you have to make it you self.
You make a secend folder and add all the files then add this folder to your rootFolder
like

IsoTrack.RootFolder.Folders.Add(SecendFolder);


#3

hello “gapilazo”

my code just doing nothing. i added all files to burn to NeroFolderClass “nRootFolder” and it’s the root class of NeroISOTrackClass “ISOTrack”. I just can’t unerstand what going on??!! :confused: :rolleyes:

private void nDrive_OnDoneCDInfo(NeroCDInfo pCDInfo)
{
	Console.WriteLine("nDrive_OnDoneCDInfo");
	cdInfo.IsWriteable = pCDInfo.IsWriteable;
	cdInfo.UnusedBlocks = pCDInfo.UnusedBlocks;
	cdInfo.FreeCapacityInBlocks = pCDInfo.FreeCapacityInBlocks;
	cdInfo.NumOfTracks = pCDInfo.Tracks.Count;

	myResetEvent.Set();
}

private void nDrive_OnDoneEstimateTrackSize(bool bOk, int BlockSize)
{
	 Console.WriteLine("nDrive_OnDoneEstimateTrackSize");        
}

private void nDrive_OnDoneImport(ref bool Ok, ref NeroFolder Folder, ref NeroCDStamp CDStamp)
{
	Console.WriteLine("nDrive_OnDoneImport");
	nRootFolder = (NeroFolderClass)Folder;
	myResetEvent.Set();
}

public void burn()
{
	DirectoryInfo dirInfo;
	string []sBackupFajli;
	NeroISOTrackClass ISOTrack = new NeroISOTrackClass();


	dirInfo = new DirectoryInfo("D:\\ALLJOKE");

	// events init
	nDrive.OnDoneBurn         += new _INeroDriveEvents_OnDoneBurnEventHandler(OnDoneBurn);
	nDrive.OnProgress         += new _INeroDriveEvents_OnProgressEventHandler(OnProgress);
	nDrive.OnDoneWaitForMedia += new _INeroDriveEvents_OnDoneWaitForMediaEventHandler(nDrive_OnDoneWaitForMedia);
	nDrive.OnAddLogLine       += new _INeroDriveEvents_OnAddLogLineEventHandler(nDrive_OnAddLogLine);
	nDrive.OnSetPhase         += new _INeroDriveEvents_OnSetPhaseEventHandler(nDrive_OnSetPhase);
	nDrive.OnAborted          += new _INeroDriveEvents_OnAbortedEventHandler(nDrive_OnAborted);
	nDrive.OnDoneCDInfo       +=new _INeroDriveEvents_OnDoneCDInfoEventHandler(nDrive_OnDoneCDInfo);
	nDrive.OnDoneImport       += new _INeroDriveEvents_OnDoneImportEventHandler(nDrive_OnDoneImport);
        
	nClass.OnFileSelImage    += new _INeroEvents_OnFileSelImageEventHandler(OnFileSelImage);
	nClass.OnMegaFatal       += new _INeroEvents_OnMegaFatalEventHandler(nClass_OnMegaFatal);
	nClass.OnNonEmptyCDRW    += new _INeroEvents_OnNonEmptyCDRWEventHandler(nClass_OnNonEmptyCDRW);
	nClass.OnWaitCD          += new _INeroEvents_OnWaitCDEventHandler(nClass_OnWaitCD);
	nClass.OnWaitCDMediaInfo += new _INeroEvents_OnWaitCDMediaInfoEventHandler(nClass_OnWaitCDMediaInfo);
	nClass.OnWaitCDReminder  += new _INeroEvents_OnWaitCDReminderEventHandler(nClass_OnWaitCDReminder);
	nClass.OnWaitCDDone      += new _INeroEvents_OnWaitCDDoneEventHandler(nClass_OnWaitCDDone);
	nClass.OnDriveStatusChanged +=new _INeroEvents_OnDriveStatusChangedEventHandler(nClass_OnDriveStatusChanged);

	// exec

	if(nDrive.DeviceReady)  // if there is media in drive
	{
		Console.WriteLine("ready");
	}
	nDrive.CDInfo(NERO_CDINFO_FLAGS.NERO_READ_CD_TEXT);
	myResetEvent.WaitOne();  // waiting to "OnDoneCDInfo" event

	nDrive.ImportIsoTrack((int)cdInfo.NumOfTracks - 1, NERO_IMPORT_ISO_TRACK_FLAGS.NERO_IMPORT_ISO_ONLY);
	myResetEvent.WaitOne();  // waiting to "OnDoneImport" event

//	AddAllToFolderRecursive(dirInfo);

	/*******************************************/
	sBackupFajli = Directory.GetFiles(@"D:\yossi1\BOOK");

	ISOTrack.RootFolder = nRootFolder;
	ISOTrack.Name = "Test";

	for(int i=0 ; i&lt;sBackupFajli.Length; i += 1)
	{
		NeroFileClass nFile = new NeroFileClass();
		nFile.SourceFilePath=sBackupFajli[i];
		nFile.Name=sBackupFajli[i].Substring(sBackupFajli[i].LastIndexOf("\\")+1);
		nRootFolder.Files.Add(nFile);
	}

	/*******************************************/

	ISOTrack.BurnOptions = (NEROLib.NERO_BURN_OPTIONS)((int)NEROLib.NERO_BURN_OPTIONS.NERO_BURN_OPTION_CREATE_ISO_FS +
							(int)NEROLib.NERO_BURN_OPTIONS.NERO_BURN_OPTION_USE_JOLIET);

	nDrive.BurnIsoAudioCD("", "", false, ISOTrack, null, null, NEROLib.NERO_BURN_FLAGS.NERO_BURN_FLAG_WRITE, 3, NEROLib.NERO_MEDIA_TYPE.NERO_MEDIA_CD);


}

can you take a look? :bow: :bow: :bow: :bow: :bow:


#4

I’ll add the file

Class1.txt (9.39 KB)


#5

sorry “gapilazo”

i just forgot to use sleep :a