Foxtable(狐表)用户栏目专家坐堂 → [求助]代码问题


  共有2107人关注过本帖树形打印复制链接

主题:[求助]代码问题

帅哥哟,离线,有人找我吗?
pcxjxjhkw
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1791 积分:12764 威望:0 精华:1 注册:2013/7/18 15:51:00
[求助]代码问题  发帖心情 Post By:2016/4/17 14:24:00 [只看该作者]

求老师将下面代码看一下,总是出问题

 

'''将扫描的档案的路径及文件名写入表中

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("添加档案结束")


 回到顶部
帅哥哟,离线,有人找我吗?
Hyphen
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/4/17 14:44:00 [只看该作者]

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("添加档案结束")

 回到顶部