search for a string in a file

Contributor
10Apr2007,18:06   #1
shah123's Avatar
How to search for a string in a file. As string might be somewhere in the middle of text file.
Code:
Console.WriteLine("Input a string ");
String data = Console.ReadLine();
sr = File.OpenText(@"C:\username.txt");

String st = sr.ReadToEnd();
?????
help please?

thanks
Go4Expert Founder
10Apr2007,18:24   #2
shabbir's Avatar
use st.Contains
Contributor
10Apr2007,18:26   #3
shah123's Avatar
Shabbir Brother you are the star. Thanks a million
Contributor
10Apr2007,18:31   #4
shah123's Avatar
One more question is

"How to find a position of that string in a file"?

Rgds,
Contributor
10Apr2007,18:44   #5
shah123's Avatar
I got the answer for position thanks anyway