Private Sub CopyFoldertoSD(lxSource As String, lxSourceFile As String, lxDest As ExternalFile,lDirectorio As Boolean)
Dim lFileName As String
Private lFile As ExternalFile, lFolder As String
Private fSD As ExternalFile, tmpSource As String, fDelete As ExternalFile
tmpSource = lxSourceFile
If lDirectorio=True Then
Try
fSD=Storage.FindDirOrCreate(lxDest,tmpSource)
Catch
MsgboxAsync (f.getlg("Couldn't Backup in this location"),f.GetLg("Backup"))
Wait For msgbox_result
Return
End Try
Else
fSD = lxDest
End If
DoEvents
For Each fex As String In File.ListFiles(lxSource)
DoEvents
If File.IsDirectory(lxSource, fex) Then
lFolder = File.Combine(lxSource, fex)
CopyFoldertoSD(lFolder,fex, fSD, True)
Continue
End If
fDelete=Storage.FindFile(fSD,fex)
If fDelete.IsInitialized Then
Storage.DeleteFile(fDelete)
End If
LblBackupFecha5.Text=fex ' here a label shows the file name being copied
Dim InputStream1 As InputStream
InputStream1 = File.OpenInput(lxSource, fex)
lFile=Storage.CreateNewFile(fSD,fex)
Dim outputstream1 As OutputStream
outputstream1= Storage.OpenOutputstream(lFile)
File.copy2(InputStream1,outputstream1)
InputStream1.Close
outputstream1.close
Next
End Sub