Dim path As String = Args(0) '''路径
Dim dt As DataTable = DataTables("扫描档案")
For Each wj As String In FileSys.GetFiles(path)
If FileSys.GetName(wj).Contains(".jpg") = True Then '''如果是图片文件
Dim str As String = FileSys.GetParentPath(wj) '''文件路径
Dim wjm As String = FileSys.GetName(wj) '''文件名
Dim n As Integer = dt.Compute("count([文件名])","路径 = '" & str & "' And 文件名 = '" & wjm & "'")
If n = 0 Then '''如果表中无此文件
Dim dr As DataRow = dt.AddNew
dr("路径") = str
dr("文件名") = wjm
End If
End If
Next
For Each pth As String In FileSys.GetDirectories(path) '''遍历子文件夹,
Functions.Execute("添加档案",pth)
Next
-------------------------------
以下2句放到外面调用函数结束后,不要放到函数中
DataTables("扫描档案").Save() '原dt.Save
MessageBox.Show("添加档案结束")