Hi guys
I still trying to fix an old problem. I have a routine that has 2 arrays, one take in the filesize from one folder from all files with an extension of .ack and the other takes in filesize from all files with an extension .ack from files in a folder that is dynamically generated every day.
The folder MYDir does exist and the files that are in it are the same as thise in the original. But when it gets to the loop to read in the contents of the sFolder2 it won't work. sFolder2 is = to MyDir which does exist???Code:Public MyNewDir As String Private Sub Sizechecking() Dim FSO As Object Set FSO = CreateObject("Scripting.FileSystemObject") Dim today As String today = Format(Now, "dd mmmm yyyy") Dim sFolder1 As String Dim sFolder2 As String Dim sFile As String Dim lCounter1 As Long Dim lCounter2 As Long Dim fileArray1() As File_Info Dim fileArray2() As File_Info ReDim fileArray1(0) ReDim fileArray2(0) sFolder1 = "D:\Orator\IBMOutgoing\" 'This is where the problem is, it won't understand that sFolder2 is = MyNewDir sFolder2 = MyNewDir 'Read Contentents of Folder sFile = Dir(sFolder1 & "*.ack") Do Until sFile = "" 'Add File Info to the array fileArray1(UBound(fileArray1)).sFileName = sFile fileArray1(UBound(fileArray1)).lFileSize = FileLen(sFolder1 & sFile) 'Expand the array for the next item ReDim Preserve fileArray1(UBound(fileArray1) + 1) sFile = Dir Loop 'Remove the last item cause its empty If UBound(fileArray1) > 0 Then ReDim Preserve fileArray1(UBound(fileArray1) - 1) End If 'Read Contentents of Folder sFile = Dir(sFolder2 & "*.ack") 'Here it read doesn't read the contents of the folder Do Until sFile = "" 'Add File Info to the array fileArray2(UBound(fileArray2)).sFileName = sFile fileArray2(UBound(fileArray2)).lFileSize = FileLen(sFolder2 & sFile) 'Expand the array for the next item ReDim Preserve fileArray2(UBound(fileArray2) + 1) sFile = Dir Loop 'Remove the last item cause its empty If UBound(fileArray2) > 0 Then ReDim Preserve fileArray1(UBound(fileArray2) - 1) End If
Please help me with this. Thanks a lot in advanceCode:sFile = Dir(sFolder2 & "*.ack") Do Until sFile = "" 'Add File Info to the array fileArray2(UBound(fileArray2)).sFileName = sFile fileArray2(UBound(fileArray2)).lFileSize = FileLen(sFolder2 & sFile) 'Expand the array for the next item ReDim Preserve fileArray2(UBound(fileArray2) + 1) sFile = Dir Loop




Reply With Quote