Follow code is part of my code to check every file's date in a directory, PathForTime, However, I found some of the subfolder may not contain "\ISIS\, and then I use IF Dir(myFileName2) <> "" to check if the subfolder exists. One error message shows up until "myFileName = Dir()". I wondered what was happened? My intention is to check if the subfolder, "ISIS", is in the directory or not? Can someone help me with this?
myFileName = Dir(PathForTime, 16)
Do While Len(myFileName) > 0
If Left(myFileName, 2) = "PE" Or Left(myFileName, 2) = "JE" Then
LotDateForSK = DateValue(FileDateTime(PathForTime & myFileName))
If LotDateForSK >= FromDateForTime And LotDateForSK <= ToDateForTime Then
myFileName2 = PathForTime & myFileName & "\ISIS\"
If Dir(myFileName2) <> "" Then
LotIDArray(LotIDTemp) = myFileName2
LotIDTemp = LotIDTemp + 1
End If
End If
End If
myFileName = Dir()
Loop
myFileName = Dir(PathForTime, 16)
Do While Len(myFileName) > 0
If Left(myFileName, 2) = "PE" Or Left(myFileName, 2) = "JE" Then
LotDateForSK = DateValue(FileDateTime(PathForTime & myFileName))
If LotDateForSK >= FromDateForTime And LotDateForSK <= ToDateForTime Then
myFileName2 = PathForTime & myFileName & "\ISIS\"
If Dir(myFileName2) <> "" Then
LotIDArray(LotIDTemp) = myFileName2
LotIDTemp = LotIDTemp + 1
End If
End If
End If
myFileName = Dir()
Loop