以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]大神帮我看下,笨死我算了  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=63354)

--  作者:半人马座比邻星
--  发布时间:2015/1/19 14:29:00
--  [求助]大神帮我看下,笨死我算了

For Each d1 As String In FileSys.GetDirectories("g:\\ce shi wen jian jia")
    Dim dr As DataRow = DataTables("表A").AddNew()
    dr("第一列") = filesys.GetName(d1)
    For Each d2 As String In FileSys.GetDirectories(d1)
        Dim dr As DataRow = DataTables("表A").AddNew
        dr("第二列") = filesys.GetName(d2)
        For Each d3 As String In FileSys.GetDirectories(d2)
            Dim dr As DataRow = DataTables("表A").AddNew()
            dr("第三列") = filesys.GetName(d3)
            Dim a As String = ""           
            For Each f4 As String In filesys.GetFiles(d3)
                If a > "" Then
                   a =  a & vbcrlf & filesys.GetName(f4)
                Else
                   a = filesys.GetName(f4)
                End If
            dr("第四列") = a
            Next
        Next
        Dim b As String = ""       
        For Each f3 As String In filesys.GetFiles(d2)
               If b > "" Then
                  b =  b & vbcrlf & filesys.GetName(f3)
               Else
                  b = filesys.GetName(f3)
               End If
        dr("第三列") = b
        Next
    Next
    Dim c As String = ""   
    For Each f2 As String In filesys.GetFiles(d1)
        If c > "" Then
           c =  c & vbcrlf & filesys.GetName(f2)
        Else
           c = filesys.GetName(f2)
        End If
    dr("第二列") = c
    Next
Next
For Each f1 As String In filesys.GetFiles("g:\\ce shi wen jian jia")
Dim d As String = ""
Dim dr As DataRow = DataTables("表A").AddNew
        If d > "" Then
           d =  d & vbcrlf & filesys.GetName(f1)
        Else
           d = filesys.GetName(f1)
        End If
     dr("第一列") = d
Next


--  作者:Bin
--  发布时间:2015/1/19 14:30:00
--  
想干嘛? 出现什么问题?
--  作者:半人马座比邻星
--  发布时间:2015/1/19 14:37:00
--  
表A / 第一列 | 第二列 |第三列|第四列 |第五列 |第六列 | 第七列 |第八列

第一行 本地磁盘F/Program Files (x86)/360/360Safe/360zip/config/zdefaultskin/zdefaultskin.exe

                                                                                                              XXOO.exe

                                                                                                              xxxooo.exe-----------三个文件是放在第一行中

--  作者:半人马座比邻星
--  发布时间:2015/1/19 14:40:00
--  

出现编译错误:变量dr在封闭块中隐藏变量

错误代码:Dim dr As DataRow = DataTables("表A").AddNew


--  作者:Bin
--  发布时间:2015/1/19 14:41:00
--  

For Each d1 As String In FileSys.GetDirectories("g:\\ce shi wen jian jia")
    Dim dr As DataRow = DataTables("表A").AddNew()
    dr("第一列") = filesys.GetName(d1)
    For Each d2 As String In FileSys.GetDirectories(d1)
        Dim dr As DataRow = DataTables("表A").AddNew
        dr("第二列") = filesys.GetName(d2)
        For Each d3 As String In FileSys.GetDirectories(d2)
            Dim dr As DataRow = DataTables("表A").AddNew()



你不能反复这样声明DR  会冲突,系统搞不清楚谁和谁, 你改为drr 或者dr8  改为不同的变量名


--  作者:半人马座比邻星
--  发布时间:2015/1/19 14:43:00
--  谢谢
谢谢,我试试去
--  作者:有点甜
--  发布时间:2015/1/19 14:44:00
--  

 不理解你到底想做什么,获取每个文件夹下的文件?

 

For Each d1 As String In FileSys.GetDirectories("g:\\ce shi wen jian jia")
    Dim dr As DataRow = DataTables("表A").AddNew()
    For Each d2 As String In FileSys.GetDirectories(d1)
        For Each d3 As String In FileSys.GetDirectories(d2)
            Dim a As String = ""
            For Each f4 As String In filesys.GetFiles(d3)
                If a > "" Then
                    a =  a & vbcrlf & filesys.GetName(f4)
                Else
                    a = filesys.GetName(f4)
                End If
               
            Next
            dr("第四列") = a
        Next
        Dim b As String = ""
        For Each f3 As String In filesys.GetFiles(d2)
            If b > "" Then
                b =  b & vbcrlf & filesys.GetName(f3)
            Else
                b = filesys.GetName(f3)
            End If
           
        Next
        dr("第三列") = b
    Next
    Dim c As String = ""
    For Each f2 As String In filesys.GetFiles(d1)
        If c > "" Then
            c =  c & vbcrlf & filesys.GetName(f2)
        Else
            c = filesys.GetName(f2)
        End If
    Next
    dr("第二列") = c
Next
For Each f1 As String In filesys.GetFiles("g:\\ce shi wen jian jia")
    Dim d As String = ""
    Dim dr As DataRow = DataTables("表A").AddNew
    If d > "" Then
        d =  d & vbcrlf & filesys.GetName(f1)
    Else
        d = filesys.GetName(f1)
    End If
    dr("第一列") = d
Next

[此贴子已经被作者于2015-1-19 14:45:35编辑过]

--  作者:半人马座比邻星
--  发布时间:2015/1/19 14:51:00
--  对的
是的是的,想让行显示路径,行的末尾显示文件
--  作者:有点甜
--  发布时间:2015/1/19 14:55:00
--  
 

For Each d1 As String In FileSys.GetDirectories("g:\\ce shi wen jian jia")
    Dim dr As DataRow = DataTables("表A").AddNew()
    dr("第一列") = d1
    For Each d2 As String In FileSys.GetDirectories(d1)
        dr("第二列") = d2
        For Each d3 As String In FileSys.GetDirectories(d2)
            dr("第三列") = d3
            Dim a As String = ""
            For Each f4 As String In filesys.GetFiles(d3)
                If a > "" Then
                    a =  a & vbcrlf & filesys.GetName(f4)
                Else
                    a = filesys.GetName(f4)
                End If
               
            Next
            dr("第四列") = a
        Next
    Next
Next