level 10
laola1000
楼主
不需要对比MD5,我不在乎文件的版本和内容。只要名字对上就OK。
求高效的思路。我现在的办法16000多个子文件,根本不敢用timer实时的监控。每次运算都卡10几秒。
为避免各位说我是伸手党,我先自己说出我的思路。求更好的办法。
我现在的思路是:
1、先把2个文件的所有文件分别写到2个数组里面;
Sub GetFullName(ByVal sPath As String, ByRef MyArr())
Dim FF, f, FuList, m_Ps, i&, k&, CoA() As String, CoB() As String
ReDim CoA(0): ReDim MyArr(0): CoA(0) = sPath
Do: i = 0: ReDim CoB(i)
For Each m_Ps In CoA
Set FF = CreateObject("Scripting.FileSystemObject").GetFolder(m_Ps)
For Each f In FF.SubFolders
If i > 0 Then ReDim Preserve CoB(i)
CoB(i) = f.Path: i = i + 1
Next
For Each f In FF.Files
If k > 0 Then ReDim Preserve MyArr(k)
MyArr(k) = Replace(f.Path, sPath, ""): k = k + 1
Next
Next
Erase CoA: CoA = CoB: Erase CoB
Loop Until i = 0
End Sub
2、然后求2个数组的补集;这里我的代码是:
Sub DelIntersec(ByRef ArrA(), ByRef ArrB())
strA = Join(ArrA, "|") & "|"
strB = Join(ArrB, "|") & "|"
For Each a In ArrA
strB = Replace(strB, a & "|", "")
Next
For Each b In ArrB
strA = Replace(strA, b & "|", "")
Next
MsgBox "A数组差缺: " & strB & Chr(13) & "B数组差缺: " & strA
End Sub
2020年06月29日 04点06分
1
求高效的思路。我现在的办法16000多个子文件,根本不敢用timer实时的监控。每次运算都卡10几秒。
为避免各位说我是伸手党,我先自己说出我的思路。求更好的办法。
我现在的思路是:
1、先把2个文件的所有文件分别写到2个数组里面;
Sub GetFullName(ByVal sPath As String, ByRef MyArr())
Dim FF, f, FuList, m_Ps, i&, k&, CoA() As String, CoB() As String
ReDim CoA(0): ReDim MyArr(0): CoA(0) = sPath
Do: i = 0: ReDim CoB(i)
For Each m_Ps In CoA
Set FF = CreateObject("Scripting.FileSystemObject").GetFolder(m_Ps)
For Each f In FF.SubFolders
If i > 0 Then ReDim Preserve CoB(i)
CoB(i) = f.Path: i = i + 1
Next
For Each f In FF.Files
If k > 0 Then ReDim Preserve MyArr(k)
MyArr(k) = Replace(f.Path, sPath, ""): k = k + 1
Next
Next
Erase CoA: CoA = CoB: Erase CoB
Loop Until i = 0
End Sub
2、然后求2个数组的补集;这里我的代码是:
Sub DelIntersec(ByRef ArrA(), ByRef ArrB())
strA = Join(ArrA, "|") & "|"
strB = Join(ArrB, "|") & "|"
For Each a In ArrA
strB = Replace(strB, a & "|", "")
Next
For Each b In ArrB
strA = Replace(strA, b & "|", "")
Next
MsgBox "A数组差缺: " & strB & Chr(13) & "B数组差缺: " & strA
End Sub