Foxtable(狐表)用户栏目专家坐堂 → [求助]能不能多线程检索


  共有2791人关注过本帖平板打印复制链接

主题:[求助]能不能多线程检索

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


加好友 发短信
等级:五尾狐 帖子:1137 积分:11230 威望:0 精华:0 注册:2017/9/26 16:30:00
[求助]能不能多线程检索  发帖心情 Post By:2018/4/4 21:35:00 [只看该作者]

论坛中的检索文档内容字符串,我测试了一下,基本检索一个文件用时1-2秒,比较耗时,能否改进加快:
http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=70797&authorid=0&page=0&star=2

mark word高亮查找

 

Dim app As New MSWord.Application
try
    Dim dlg As New FolderBrowserDialog
    If dlg.ShowDialog = DialogResult.Ok Then
        MessageBox.Show("需要检索的文档目录是:" & dlg.SelectedPath,"提示")
    End If
    Dim s As String = ""
    For Each file As String In FileSys.GetFiles(dlg.SelectedPath)
        If file.ToLower.EndsWith(".doc") Then
            Dim doc = app.Documents.Open(file)
            Dim gjzs As String = "Test|Abcdefg|test"
            Dim flag As Boolean = False
            For Each gjz As String In gjzs.split("|")
                app.ActiveWindow.Selection.WholeStory
                With app.ActiveWindow.Selection.Find
                    .HitHighlight(gjz, RGB(255, 255, 0), , , , , , , True)
                End With
                If app.ActiveWindow.Selection.Find.Execute Then flag = True
            Next
            If flag = False  Then
                Doc.close
            Else
                s = s & IIF(s>"", chr(13), "") & file
            End If
        End If
    Next
    If s > "" Then
        MessageBox.Show("共计找到包含关键字的文档有" & s.Split(chr(13)).Length & "个,目录如下:" & vbcrlf & s,"关键字文档查找",MessageBoxButtons.OK,MessageBoxIcon.None)
        app.Visible = True
    Else
        MessageBox.Show("没有找到包含关键字的文档","关键字文档查找",MessageBoxButtons.OK,MessageBoxIcon.None)
        app.quit
    End If
    
catch ex As exception
    msgbox(ex.message)
    app.Quit
finally
End try


 回到顶部