Burn Multi Directorys Help

vbimport

#1

Hi

What I need to do is burn multi Directorys to a DvD using nerocom.dll

I have found the follwoing code :

'Recursive function to build the Folders/Files to burn
Private Sub BuildFileFolderTree(ByRef nroFolderToUse As NeroFolder, ByRef folCurrent As Folder)
Dim folTMP As Folder
Dim filTMP As File
Dim nroFolTmp As NeroFolder
Dim nroFilTmp As NeroFile

'Add all files in the current directory
For Each filTMP In folCurrent.Files
Set nroFilTmp = New NeroFile
nroFilTmp.Name = filTMP.Name
nroFilTmp.SourceFilePath = filTMP.Path
nroFolderToUse.Files.Add nroFilTmp
Next

'Write the sub folders
For Each folTMP In folCurrent.SubFolders
Set nroFolTmp = New NeroFolder
nroFolTmp.Name = folTMP.Name
nroFolderToUse.Folders.Add nroFolTmp
Call BuildFileFolderTree(nroFolTmp, folTMP)
Next

End Sub

This works but is not what I need.

I have a folder structure stored on an array from # to z i.e

\server\store#
\server\store\A
\server\store\Z\

Under this each folder structure there are sub folders i.e

\server\store#\1
\server\store#\2\

ect ect

What I need to do is create the nerocom folder collection from this, ideally it would be read from a text file or clipboard in the format of :

\server\store#\1
\server\store\A\2
\server\store\Z\1\

The folder that is added may or may not have sub folders. i.e

\server\store#\1\1
\server\store#\1\2
\server\store\A\2
\server\store\Z\1\1
\server\store\Z\1\12

Im useless at collections and folder recursion.

Any Help will be Greatly Appriciated.

Regards


#2

To clarify do you want to copy the whole contents of \server\store?

Mike


#3

No

Just Selected Directorys, from different paths

Regards


#4

Im useless at collections and folder recursion.
Your requirement does not seem too complicated but if you want it done programmatically, you really need to get involved with collections and folder recursion or find somebody to do it for you.


#5

Its not the folder recursion so much I can do that its how to pass it to the nero folder collection.

I can write selected folders without sub dirs ok, but its when it comes down to the folder having sub directories Im doing something wrong.

Dim folTMP As Folder
Dim filTMP As file
Dim nroFolTmp As NeroFolder
Dim nroFilTmp As NeroFile

Dim folTMP2 As Folder
Dim filTMP2 As file
Dim nroFolTmp2 As NeroFolder
Dim nroFilTmp2 As NeroFile
Dim x As Integer
Dim subs_count As Integer

Set nroFolTmp = New NeroFolder
nroFolTmp.Name = folCurrent.Name
nroFolderToUse.Folders.Add nroFolTmp

If folCurrent.SubFolders.Count > 0 Then

For Each folTMP2 In folCurrent.SubFolders

Set nroFolTmp2 = New NeroFolder

nroFolTmp2.Name = folTMP2.Name

’ Its in here Im Haveing The Problem ???
nroFolderToUse.Folders.Add nroFolTmp2

’ This Creates The Subdir in The Root of The DvD, instead of the parent root

Next

Else

''Add all files in the current directory
For Each filTMP In folCurrent.Files
Set nroFilTmp = New NeroFile
nroFilTmp.Name = filTMP.Name
StatusBar1.SimpleText = filTMP.Name
nroFilTmp.SourceFilePath = filTMP.Path
nroFolTmp.Files.Add nroFilTmp
'Debug.Print nroFilTmp.SourceFilePath
Next

End If

Regards


#6

nroFolderToUse.Folders.Add nroFolTmp2

’ This Creates The Subdir in The Root of The DvD, instead of the parent root
Assuming BuildFileFolderTree is called with the ISO track’s root folder as the first ByRef parameter, calling nroFolderToUse.Folders.Add effectively adds the nroFolTmp2 to the folders collection, which in turn causes the nroFolTmp2 folder to appear in the root of the disc.

If this is not what you want, you should instead enumerate all nroFolTmp2’s files and folders and add them to nroFolderToUse.Folders and nroFolderToUse.Files collections. By doing so, all files/folders contained in the nroFolTmp2 will magically appear in the disc root.


#7

Stiil struggling to get my head around this, can I be cheeky !!
any chance of some example source code. :wink:


#8

After searching the net, I have finally found the code I needed, a big thankyou to princew for this code

See http://club.cdfreaks.com/lite/t-88506

Seem’s there is not a lot of info for what I have found to do this, this works A1.

'///////////////////////////////////////////////////////////////////////
'global

Public fs As New FileSystemObject
Public WithEvents myNero As nero
Public WithEvents myNeroDrive As NeroDrive
Public myNeroDrives As NeroDrives

'///////////////////////////////////////////////////////////////////////
Private Sub Form_Initialize()
Set myNero = New nero
Set myNeroDrives = myNero.GetDrives(NERO_MEDIA_DVD_ANY)

For i = 0 To (myNeroDrives.Count - 1)
AvailableDevices.AddItem myNeroDrives(i).DeviceName
Next

AvailableDevices.ListIndex = 0

ErrHandler:
Exit Sub
End Sub
'///////////////////////////////////////////////////////////////////////
Public Sub get_disc_files()
Dim myFolder As folder
Dim myRootNeroFolder As NeroFolder

’ create the iso root folder first
Set myRootNeroFolder = New NeroFolder
myRootNeroFolder.Name = “SomeName”

’ use ms filesystem to get the folder you want to add to the cd
Set myFolder = fs.GetFolder(“full path to a folder here”)

’ add it to the root folder using the recursive “add_folder_files()” function (defined below)
myRootNeroFolder.folders.Add add_folder_files(myFolder)

’ repeate the 2 calls above as many times as you like to add different folders to the root

’ set up the isotrack
Set myNeroISOtrack = New NeroISOTrack
myNeroISOtrack.Name = txtTitle.Text
myNeroISOtrack.RootFolder = myRootNeroFolder
myNeroISOtrack.BurnOptions = NERO_BURN_OPTION_CREATE_ISO_FS + NERO_BURN_OPTION_USE_JOLIET

’ set the correct drive here
Set myNeroDrive = myNeroDrives(AvailableDevices.ListIndex)

’ burn the disc
myNeroDrive.BurnIsoAudioCD “aaaa”, “bbbb”, 0, myNeroISOtrack, Nothing, Nothing, NERO_BURN_FLAG_WRITE, 32, NERO_MEDIA_CD
End Sub
'///////////////////////////////////////////////////////////////////////
’ notice this function returns a NeroFolder. This makes it easy to add the entire tree to an existing NeroFolder

Public Function add_folder_files(dir) As NeroFolder
Dim myNeroFolder As NeroFolder
Dim myNeroFile As NeroFile

Dim myFile As file
Dim myFolder As folder
Dim myFiles As Files
Dim myFolders As folders

’ get the folder and files for this folder
Set myFolder = fs.GetFolder(dir.Path)
Set myFolders = myFolder.SubFolders
Set myFiles = myFolder.Files

’ create a new nero folder and name it
Set myNeroFolder = New NeroFolder
myNeroFolder.Name = dir.Name

’ add all the files to the nero folder
For Each myFile In myFiles
Set myNeroFile = New NeroFile
myNeroFile.Name = myFile.Name
myNeroFile.SourceFilePath = myFile.Path
myNeroFolder.Files.Add myNeroFile
Next

’ add all of the folders to the nero folder
For Each myFolder In myFolders
myNeroFolder.folders.Add add_folder_files(myFolder)
Next

’ return this folder
Set add_folder_files = myNeroFolder
End Function