求老师将下面代码看一下,总是出问题
'''将扫描的档案的路径及文件名写入表中
Dim path As String = Args(0) '''路径
Dim dt As DataTable = DataTables("扫描档案")
If FileSys.GetFiles(path).Count > 0 Then
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
End If
If FileSys.GetDirectories(path).count > 0 Then
For Each pth As String In FileSys.GetDirectories(path) '''遍历子文件夹,
If FileSys.GetFiles(pth).Count > 0 Then
For Each wj As String In FileSys.GetFiles(pth) '''遍历子文件夹下的文件
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
End If
If FileSys.GetDirectories(pth).Count > 0 Then '''如果还有子文件
Functions.Execute("添加档案")
End If
Next
End If
dt.Save
MessageBox.Show("添加档案结束")