Add files and folders


can somone give me code exmple of a function that adds Recursively files and folder.

many thanks.

What language are you using?

I have the same question as zikman’s. I’m using VB. Thanks in advance.

c++ mfc

I havent done exactly what you guys are looking for, but I can give you all generally what you need. First the recursive function for finding the directories…

recursiveFn(string dir)
WIN32_FIND_DATA findData;
HANDLE hFind=FindFirstFile((dir+"\.").c_str(), &findData);

do {
string sFileName(findData.cFileName); //sFileName will contain the name of the file or directory
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // is a directory
//do the directory stuff (recurse etc)
// you know you have a file

}while (FindNextFile(hFind, &findData));

I used somethign like this and stored the results in what was basically a vector of filepaths.

For the burning, you will need to create a bunch of NERO_ISO_ITEMS. Its really just a linked list or items.

Once you have the data structure that is holding the files and directories that you want to burn, you just need to loop or recurse through the items.

As you go along, keep creating new NERO_ISO_ITEMS and fill in the filename and the sourceFilePath for the items.
As you iterate through, you need to keep track of 2 or 3 NERO_ISO_ITEMS at once, and this is really the key to building the list. As you create new items, they get attached to the list via setting their previous siblings ->nextItem to them. If the item is a directory, you set the isDirectory part of the NERO_ISO_ITEM to true, and if it has items in it, you add them by setting the subDirFirstItem on the first one, and then just attaching the other files/directories in there using the nextItem field.

Keep track of whatever your initial NERO_ISO_ITEM was that you created. After you are done attaching all of the siblings and subdirectories, you need to use something like this: m_DVD.nwcdIsoTrack = NeroCreateIsoTrackEx(m_RootItem, m_sDiscTitle, NCITEF_CREATE_ISO_FS|NCITEF_USE_JOLIET|NCITEF_CREATE_UDF_FS);

Where the m_DVD is your NERO_WRITE_CD.

Obviously, there is alot of other NERO things that need to be initialized, and settings that have to be set, but you can basically copy and paste almost 100% of that from the NeroFiddles code.

Just a few notes:

  • FindFirstFile may return INVALID_HANDLE_VALUE

  • Remember to skip “dots” directories ("." and “…”)

  • The hFind handle must be closed after the while loop, otherwise the NT system will sooner or later close your application. In my personal experience, closing an INVALID_HANDLE_VALUE will extremely slow down the process for whatever reason, so it would be best to “if (hFile != INVALID_HANDLE_VALUE) ::FindClose(hFind);”.