以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  为什么提取的文件名缺了很多?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=68675)

--  作者:南望
--  发布时间:2015/5/22 11:28:00
--  为什么提取的文件名缺了很多?
为什么提取的文件名缺了很多?即提取的文件名不完整

单击事件:

Dim Book As New XLS.Book \'定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表
Sheet(0, 0).Value = "文件名"
Dim r As Integer = 1

Dim FilePath As WinForm.TextBox = e.Form.Controls("TextBox1")

If FileSys.DirectoryExists(FilePath.Value) Then
    Functions.Execute("文件名提取函数", FilePath.Text, Sheet, r)
End If

Book.Save("c:\\reports\\test.xls")


递归函数:

Dim path As String = args(0)
Dim Sheet As XLS.Sheet = args(1)
Dim r As Integer = args(2)

For Each file As String In FileSys.GetFiles(path)
    Dim Ifo As new FileInfo(file)
    If Ifo.hidden=False Then
        sheet(r,0).value = file
        r += 1
    End If
Next


For Each p As String In FileSys.GetDirectories(path)
    Functions.Execute("文件名提取函数", p, Sheet, r)
Next

--  作者:南望
--  发布时间:2015/5/22 11:29:00
--  
例如:明明是5个目录9个文件,但只提取了3个目录6个文件
--  作者:大红袍
--  发布时间:2015/5/22 11:31:00
--  

 

[此贴子已经被作者于2015/5/22 11:34:26编辑过]

--  作者:大红袍
--  发布时间:2015/5/22 11:33:00
--  

 

[此贴子已经被作者于2015/5/22 11:34:12编辑过]

--  作者:Bin
--  发布时间:2015/5/22 11:35:00
--  
For Each p As String In FileSys.GetDirectories(path)
    \'你在这里获取了下级文件夹路径, 但是并没有储存到任何地方去, 所以你只是提取文件名, 并没有提取目录
    Functions.Execute("文件名提取函数", p, Sheet, r)
Next

--  作者:大红袍
--  发布时间:2015/5/22 11:38:00
--  

 嗯嗯,是写入excel的时候有点问题了,行数必须累加

 

单击事件:


Dim Book As New XLS.Book \'定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表
Sheet(0, 0).Value = "文件名"
vars("r") = 1


Dim FilePath As WinForm.TextBox = e.Form.Controls("TextBox1")


If FileSys.DirectoryExists(FilePath.Value) Then
    Functions.Execute("文件名提取函数", FilePath.Text, Sheet)
End If


Book.Save("c:\\reports\\test.xls")

 


递归函数:


Dim path As String = args(0)
Dim Sheet As XLS.Sheet = args(1)
Dim r As Integer = vars("r")


For Each file As String In FileSys.GetFiles(path)
    Dim Ifo As new FileInfo(file)
    If Ifo.hidden=False Then
        sheet(r,0).value = file
        r += 1
    End If
Next

vars(r) = r
For Each p As String In FileSys.GetDirectories(path)
    Functions.Execute("文件名提取函数", p, Sheet)
Next


--  作者:南望
--  发布时间:2015/5/22 13:49:00
--  
刚刚试过了,提取的个数还是缺少。
--  作者:南望
--  发布时间:2015/5/22 13:53:00
--  
麻烦老师做到例子里测试一下吧
--  作者:大红袍
--  发布时间:2015/5/22 14:12:00
--  

 

[此贴子已经被作者于2015/5/22 14:14:57编辑过]

--  作者:大红袍
--  发布时间:2015/5/22 14:16:00
--  

写错了

 

单击事件:


Dim Book As New XLS.Book \'定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表
Sheet(0, 0).Value = "文件名"
vars("r") = 1


Dim FilePath As WinForm.TextBox = e.Form.Controls("TextBox1")


If FileSys.DirectoryExists(FilePath.Value) Then
    Functions.Execute("文件名提取函数", FilePath.Text, Sheet)
End If


Book.Save("c:\\reports\\test.xls")

 


递归函数:


Dim path As String = args(0)
Dim Sheet As XLS.Sheet = args(1)
Dim r As Integer = vars("r")


For Each file As String In FileSys.GetFiles(path)
    Dim Ifo As new FileInfo(file)
    If Ifo.hidden=False Then
        sheet(r,0).value = file
        r += 1
    End If
Next

vars("r") = r
For Each p As String In FileSys.GetDirectories(path)
    Functions.Execute("文件名提取函数", p, Sheet)
Next