Probleme sind im Code beschrieben. Code ist testbar.
Code: Alles auswählen
EnableExplicit
Global dirzaehler=0
Global diranzahl=0
Global pfad$, x , startdir$
Global Dim verzeichnis$(4000)
Global FontID1
FontID1 = LoadFont(1, "Arial", 14)
Declare putFTPdirs(pfad$)
Declare.s FormatByteSize(n.q)
startdir$ = "c:\test" ; hier anpassen (Hat hier im Test 2 Unterordner)
OpenWindow(0,0,0,400,150,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
TextGadget(1, 50, 30, 300, 30, "Backup wird gestartet . . .", #PB_Text_Center)
SetGadgetFont(1, FontID1)
TextGadget(2, 50, 70, 300, 30, "Backup wird gestartet . . .", #PB_Text_Center)
SetGadgetFont(2, FontID1)
Procedure putFTPdirs(pfad$)
Protected gesamtbyte
Protected Ergebnis
Protected verz1$
Protected dirzaehler
Protected diranzahl
Protected Ereignis
Debug pfad$
; Hier sollten der Ordner und Unterordner durchlaufen, aber funktioniert nur halb(Es fehlt der 2.Unterordner)
SetCurrentDirectory(pfad$)
ExamineDirectory(1, pfad$,"")
While NextDirectoryEntry(1)
If DirectoryEntryType(1)=#PB_DirectoryEntry_Directory
verz1$=DirectoryEntryName(1)
If verz1$<>".." And verz1$<>"."
diranzahl+1
Ereignis = WindowEvent()
SetGadgetText(1,"analyze directory : "+Str(diranzahl))
verzeichnis$(diranzahl)=pfad$+verz1$+"\"
EndIf
Else
gesamtbyte=gesamtbyte+DirectoryEntrySize(1)
SetGadgetText(2,"Total-Bytes : "+FormatByteSize(gesamtbyte)) ; Da ein Unterordner fehlt, stimmt gesamtbyte natürlich nicht.
EndIf
Wend
If dirzaehler<diranzahl
dirzaehler+1
putFTPdirs(verzeichnis$(dirzaehler))
EndIf
Debug "diranzahl nach Schleife ; "+ diranzahl
EndProcedure
Procedure.s FormatByteSize(n.q)
Protected s.s=Str(n)
Protected len=Len(s)
Protected ret.s
Protected i
For i=0 To len-1
If i And Not i%3 :: ret="."+ret :: EndIf
ret= Mid(s,len-i,1) +ret
Next
ProcedureReturn ret
EndProcedure
verzeichnis$(diranzahl)=startdir$
putFTPdirs(startdir$+"\")
Debug "dirnumbers for copy = "+ diranzahl
;Hier sollte als dirnumbers 2 nicht 0 erscheinen , und ich habe nicht herausfinden können warum
For x=0 To diranzahl
; getFTPfiles(verzeichnis$(x)) ;;;;; diese Procedure übernimmt dann das erstellen der Ordner auf dem Server und das übertragen der Dateien.Habe jetz hier zum Test diese Procedure weggelassen.
Next
Repeat
Select WaitWindowEvent(20)
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver