利用函数+代码来实现目录文件扫描入库(sql),刚开始速度达到700个文件/秒,到后来只有1个/秒
有办法解决吗?
函数如下:
Dim path As String = args(0)
Dim ls = args(1)
For Each file As String In FileSys.GetFiles(path)
ls.add(file)
Dim ifo As New FileInfo(file)
If ifo.Extension = ".doc" Or ifo.Extension = ".docx" Or ifo.Extension = ".png" Or ifo.Extension = ".pdf" Or ifo.Extension = ".xlsx" Or ifo.Extension = ".zip" Or ifo.Extension = ".wps" Or ifo.Extension = ".jpg" Or ifo.Extension = ".pptx" Or ifo.Extension = ".txt" Or ifo.Extension = ".xls" Or ifo.Extension = ".bmp" Or ifo.Extension = ".jpeg" Or ifo.Extension = ".rar" Or ifo.Extension = ".ppt" Or ifo.Extension = ".chm" Or ifo.Extension = ".7z" Or ifo.Extension = ".dotx" Then '非此类文件不加载
Dim r As Row = Tables("文件加载中转").addnew '表增加新行
r("路径") = file '文件名及路径赋值到对应列
r("文件名") = FileSys.GetName(file) '获取去掉路径的文件名赋值到对应列
r("创建时间") = ifo.CreationTime
r("最后修改时间") = ifo.LastWriteTime
r("文件大小") = ifo.Length
r("文件类型") = ifo.Extension
Else
End If
Next
For Each p As String In FileSys.GetDirectories(path) '循环调用自身代码
Functions.Execute("ftp文件递归", p, ls)
Next
代码如下:
If DataTables.Contains("hplnpf") = False Then '如果表没有加载
DataTables.Load("hplnpf") '加载表"
End If
MainTable = Tables("hplnpf") '切换表
Dim lg As New List(Of String)
Functions.Execute("ftp文件递归", "D:\电子文档管理", lg)
[此贴子已经被作者于2023/5/5 18:04:10编辑过]