Here is an example:
Code:Private Type File_Info sFileName As String lFileSize As Long End Type Private Sub Form_Load() Dim sFolder1 As String Dim sFolder2 As String Dim sFile As String Dim lCounter1 As Long Dim lCounter2 As Long Dim fiArray1() As File_Info Dim fiArray2() As File_Info ReDim fiArray1(0) ReDim fiArray2(0) sFolder1 = "C:\Folder1\" sFolder2 = "C:\Folder2\" 'Read Contentents of Folder sFile = Dir(sFolder1 & "*.*") Do Until sFile = "" 'Add File Info to the array fiArray1(UBound(fiArray1)).sFileName = sFile fiArray1(UBound(fiArray1)).lFileSize = FileLen(sFolder1 & sFile) 'Expand the array for the next item ReDim Preserve fiArray1(UBound(fiArray1) + 1) sFile = Dir Loop 'Remove the last item cause its empty If UBound(fiArray1) > 0 Then ReDim Preserve fiArray1(UBound(fiArray1) - 1) End If 'Read Contentents of Folder sFile = Dir(sFolder2 & "*.*") Do Until sFile = "" 'Add File Info to the array fiArray2(UBound(fiArray2)).sFileName = sFile fiArray2(UBound(fiArray2)).lFileSize = FileLen(sFolder2 & sFile) 'Expand the array for the next item ReDim Preserve fiArray2(UBound(fiArray2) + 1) sFile = Dir Loop 'Remove the last item cause its empty If UBound(fiArray2) > 0 Then ReDim Preserve fiArray1(UBound(fiArray2) - 1) End If If UBound(fiArray1) > 0 And UBound(fiArray2) > 0 Then 'Start Compare For lCounter1 = LBound(fiArray1) To UBound(fiArray1) For lCounter2 = LBound(fiArray2) To UBound(fiArray2) If fiArray1(lCounter1).lFileSize = fiArray2(lCounter2).lFileSize Then Debug.Print fiArray1(lCounter1).sFileName & " has the same size as " & fiArray2(lCounter2).sFileName End If Next Next End If End Sub




Reply With Quote