在文本文件中找到特定的单词 [英] find a specific word in text file
本文介绍了在文本文件中找到特定的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hai,
如何使用vb.net
hai ,
how to search a particular words in text file using vb.net
推荐答案
在文本文件中搜索特定单词将文本文件的一部分(例如一行)读取到String
对象中,然后使用String.IndexOf
方法.
Read a chunk of the text file, for instance a line, into aString
object and then use theString.IndexOf
method.
使用此代码在文本文件中查找特定单词
Use this code to find specific word in text file
Dim InputStr As String = TextBox1.Text
For Each FileStr As String In IO.Directory.GetFiles("C:\your folder", "*.txt")
If IO.File.ReadAllText(FileStr).IndexOf(InputStr) >= 0 Then
ListBox1.Items.Add(IO.Path.GetFileName(FileStr))
End If
Next
谢谢
SP
Thanks
SP
这篇关于在文本文件中找到特定的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文