Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
'Folder variables must end in \
#Compile Exe
#Dim All
#Debug Error On
#Debug Display On
#Include "Win32API.inc"
Global hDlg,hThread As Dword, iResult As Long
Global tempA As DirData, DirA, DirB, DirC As String
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
Local temp$, s As Long
Kill DirC + "*.*" '<--------remove file in 3rd folder
DirA = "c:\tempA\" : DirB = "c:\tempB\" : DirC = "c:\tempC\"
temp$ = Dir$(DirA + "*.*", %Normal, To tempA)
While Len(temp$)
Thread Create IsNewFile(0) To hThread 'works on Global tempA, DirA, DirB
'<---- wait for thread to complete
Thread Close hThread To iResult
If iResult Then FileCopy DirA + temp$, DirC + temp$
temp$ = Dir$(Next To tempA)
Wend
End If
End Function
Thread Function IsNewFile(ByVal Dummy As Long) As Long
Local temp$, tempB As DirData
iResult = 0
temp$ = Dir$(DirB + tempA.filename, 0, To tempB)
If Len(temp$) = 0 Then iResult = 1 : Exit Function 'is file new (does not exist in DirB)
If tempA.LastWriteTime < tempB.LastWriteTime Then iResult = 1 'is file in DirA newer than file in DirB
End Function
'gbs_01266
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm