Copy folder on a cd using vb

vbimport

#1

hi
first sorry for my english

i have downloaded this code is work fine
but it’s add only single files and i need to burn a Folder for my backup
i dont know so much in vb code
please can you help me to change this code
tanks

this is the code:

Private Declare Function GetDriveType Lib “kernel32” Alias “GetDriveTypeA” (ByVal nDrive As String) As Long
Private Declare Function GetLogicalDriveStrings _
Lib “kernel32.dll” _
Alias “GetLogicalDriveStringsA” _
( _
ByVal nBufferLength As Long, _
ByVal lpBuffer As String _
) _
As Long

Public WithEvents nero As nero
Public Drives As INeroDrives
Public WithEvents Drive As NeroDrive
Public cnt As Integer
Public Folder As INeroFolder
Public strMessages As String

Private Sub cmdAbort_Click()

nero.Abort
MsgBox "Procedure interrompue par l'utilisateur ", vbCritical, ""

End Sub

Private Sub cmdErase_Click()

Set Folder = New NeroFolder
Dim Drives As INeroDrives
Set Drives = nero.GetDrives(NERO_MEDIA_CDR)
Set Drive = Drives(AvailableDevices.ListIndex)
Dim isotrack As NeroISOTrack
Set isotrack = New NeroISOTrack

isotrack.BurnOptions = NERO_BURN_OPTION_USE_JOLIET Or NERO_BURN_OPTION_CREATE_ISO_FS

handle_error:
strMessages = strMessages + Err.Description + Chr(13) + Chr(10) + nero.LastError
edtMessages = strMessages
quit:

End Sub

Private Sub CmdBurn_Click()
Set Folder = New NeroFolder

Dim Drives As INeroDrives
Set Drives = nero.GetDrives(NERO_MEDIA_CDR)
Set Drive = Drives(AvailableDevices.ListIndex)

Dim isotrack As NeroISOTrack
Set isotrack = New NeroISOTrack
isotrack.Name = Text1.Text
isotrack.RootFolder = Folder

Dim nFiles() As New NeroFile
ReDim Preserve nFiles(Elenco.ListCount) ‘’ array files
Dim i As Integer
For i = 0 To Elenco.ListCount - 1
nFiles(i).Name = NameFromPath(Elenco.List(i))
nFiles(i).SourceFilePath = Elenco.List(i)
Folder.Files.Add nFiles(i)
Next i

isotrack.BurnOptions = NERO_BURN_OPTION_USE_JOLIET Or NERO_BURN_OPTION_CREATE_ISO_FS
Drive.BurnIsoAudioCD “”, “”, False, isotrack, Nothing, Nothing, NERO_BURN_FLAG_WRITE, 4, NERO_MEDIA_CD
GoTo quit

handle_error:
strMessages = strMessages + Err.Description + Chr(13) + Chr(10) + nero.LastError
edtMessages = strMessages
quit:

End Sub

Private Function FolderExists(strPAth As String) As Boolean
On Error Resume Next
FolderExists = GetAttr(strPAth) And vbDirectory
End Function

Private Sub FileAdd_Click()

SelectFileDialog.CancelError = True
On Error GoTo ErrHandler
SelectFileDialog.Flags = cdlOFNHideReadOnly
SelectFileDialog.FilterIndex = 2
SelectFileDialog.ShowOpen
Elenco.AddItem SelectFileDialog.FileName

ErrHandler:
Exit Sub
End Sub

Private Sub Form_Initialize()
Set nero = New nero
ProgressBar.Value = 0
strMessages = “”

Dim Drives As INeroDrives
Set Drives = nero.GetDrives(NERO_MEDIA_CDR)

For myIndex = 0 To Drives.Count - 1
AvailableDevices.AddItem Drives(myIndex).DeviceName, myIndex
Next
AvailableDevices.ListIndex = 0
ErrHandler:
Exit Sub
End Sub

Private Sub nero_OnMegaFatal()

strMessages = strMessages + "A mega fatal error has occurred." + Chr(13) + Chr(10)
edtMessages = strMessages

End Sub

Private Sub nero_OnNonEmptyCDRW(Response As NEROLib.NERO_RESPONSE)
strMessages = strMessages + “CD-RW not empty!” + Chr(13) + Chr(10)
edtMessages = strMessages
Response = NERO_RETURN_EXIT
End Sub

Private Sub drive_OnAborted(Abort As Boolean)
Abort = False
End Sub

Private Sub drive_OnAddLogLine(TextType As NEROLib.NERO_TEXT_TYPE, Text As String)
strMessages = strMessages + Text + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Private Sub drive_OnDoneBurn(StatusCode As NEROLib.NERO_BURN_ERROR)
strMessages = strMessages + Chr(13) + Chr(10) + nero.ErrorLog + Chr(13) + Chr(10)
strMessages = strMessages + nero.LastError + Chr(13) + Chr(10)
strMessages = strMessages + "Burn finished "
If StatusCode <> NEROLib.NERO_BURN_OK Then
strMessages = strMessages + “NOT (” & StatusCode & “)”
End If
strMessages = strMessages + “successfully!” + Chr(13) + Chr(10)
edtMessages = strMessages

ProgressBar.Value = 0

End Sub

Private Sub drive_OnDoneWaitForMedia(Success As Boolean)
strMessages = strMessages + “Done waiting for media.” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Private Sub drive_OnProgress(ProgressInPercent As Long, Abort As Boolean)
Abort = False
ProgressBar.Value = ProgressInPercent
End Sub

Private Sub drive_OnSetPhase(Text As String)
strMessages = strMessages + Text + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Function NameFromPath(strPAth As String) As String
Dim lngPos As Long
Dim strPart As String
Dim blnIncludesFile As Boolean

lngPos = InStrRev(strPAth, "\")
blnIncludesFile = InStrRev(strPAth, ".") &gt; lngPos
strPart = ""

If lngPos &gt; 0 Then
    If blnIncludesFile Then
        strPart = Right$(strPAth, Len(strPAth) - lngPos)
    End If
End If

NameFromPath = strPart

End Function

Private Sub nero_OnRestart()
strMessages = strMessages + “The system is being restarted.” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Private Sub nero_OnWaitCD(WaitCD As NEROLib.NERO_WAITCD_TYPE, WaitCDLocalizedText As String)
strMessages = strMessages + WaitCDLocalizedText + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub
Private Sub nero_OnWaitCDDone()
strMessages = strMessages + “Done waiting for CD.” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Private Sub nero_OnWaitCDMediaInfo(LastDetectedMedia As NEROLib.NERO_MEDIA_TYPE, LastDetectedMediaName As String, RequestedMedia As NEROLib.NERO_MEDIA_TYPE, RequestedMediaName As String)
strMessages = strMessages + “Waiting for a particular media type:” + Chr(13) + Chr(10)
strMessages = strMessages + RequestedMediaName + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Private Sub nero_OnWaitCDReminder()
strMessages = strMessages + “Still waiting for CD…” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Private Sub nero_OnFileSelImage(FileName As String)
ImageFileDialog.CancelError = True
On Error GoTo ErrHandler
ImageFileDialog.Flags = cdlOFNHideReadOnly
ImageFileDialog.FilterIndex = 2
ImageFileDialog.ShowOpen
FileName = ImageFileDialog.FileName
Exit Sub
ErrHandler:
Exit Sub
End Sub