Using the FIND Method in a TXT DOC.
Posted on 2007-08-01
I'm want to use the FIND Method (or something similar) to search a text document, which contains a list of words (one word per line). I've been able to do what I want, if I put the list into a RichTextBox and use the following code:
myIndex= RichTextBox1.Find("string1") '>> string1 is the word I'm searching for in the list.
This either sets the integer, myIndex to "-1", meaning it could not find what I was looking for, or it returns an integer (> 0) meaning it did find my string somewhere in the list.
However, how would I do that if I simply wanted to open a TXT document in memory and FIND the string I'm searching for right from that TXT document without loading its contents into a RTB (which I don't want to do)?
I assume I'd use Streamreader to open and read the document, but then how would I use the FIND command with Streamreader? -- Is there a better way?