我知道遍历文件代码混合读取文本代码就会产生下图所示效果
vb.net吧
全部回复
仅看楼主
level 7
暴牙归来 楼主
混合后的代码:
Option Explicit On
Imports System.IO
Private FilePackage() As String
Dim line As String
Dim txtfileadress As String
Dim sr As IO.StreamReader
Dim DirPackage() As String
Dim SearchString As String
Dim DirString As String
Dim I As Long, J As Long, K As Long
Erase FilePackage
ReDim DirPackage(0)
DirPackage(0) = Me.FolderBrowserDialog1.SelectedPath & "\"
SearchString = "*.txt"
Do While I <= J
DirString = Dir(DirPackage(I), vbHidden Or vbDirectory Or vbReadOnly Or vbSystem)
Do While DirString <> ""
If DirString <> "." And DirString <> ".." Then
If (GetAttr(DirPackage(I) & DirString) And vbDirectory) = vbDirectory Then
J = J + 1
ReDim Preserve DirPackage(J)
DirPackage(J) = DirPackage(I) + DirString + "\"
Else
If UCase(DirString) Like UCase(SearchString) Then
FilePackage(K) = DirPackage(I) + DirString
K = K + 1
txtfileadress=FilePackage(K)
sr = IO.File.OpenText(txtfileadress)
Do While (sr.Peek <> -1)
line = sr.ReadLine
If line.Contains("文本中的信息") = True Then
MsgBox("该文本中还有指定信息")
End If
Loop
End If
End If
End If
DirString = Dir
Loop
I = I + 1
Loop
2016年06月21日 14点06分 1
level 7
暴牙归来 楼主
但我运行后是这样的
死机·········死机···········@夜闻香 @杰克动人之怒
2016年06月21日 14点06分 2
level 7
暴牙归来 楼主
2016年06月21日 14点06分 3
level 13
看不懂你在写什么。似乎用了很多旧版的库函数。
---贴吧极速版 For UWP
2016年06月21日 14点06分 4
level 13
这个示例在用户的文档文件夹查找*.docx文件。如果编制过索引,查询会十分迅速。
' Set query options with filter and sort order for results
Try
  ' Create index backed file query and get results
  Dim fileTypeFilter As New List(Of String)
  fileTypeFilter.Add(".docx")
  Dim queryOptions As New QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByName, fileTypeFilter)
  queryOptions.IndexerOption = IndexerOption.OnlyUseIndexer
  Dim queryResult = Windows.Storage.KnownFolders.DocumentsLibrary.CreateFileQueryWithOptions(queryOptions)
  Dim files = Await queryResult.GetFilesAsync()
  ' Process resulting files
  If files.Count = 0 Then
    ' Perform tasks to handle no files found
  Else
    ' Access properties for each file
    For Each file In files
      Dim documentProperties = Await file.Properties.GetDocumentPropertiesAsync()
      ' Perform tasks with document properties
      Dim title As String = documentProperties.Title
    Next
  End If
' Handle errors with catch blocks
' For example, handle a file not found error
Catch ex As FileNotFoundException
End Try
---贴吧极速版 For UWP
2016年06月21日 14点06分 5
1