Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   search for a string in a file (http://www.go4expert.com/forums/search-string-file-t3821/)

shah123 10Apr2007 18:06

search for a string in a file
 
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

shabbir 10Apr2007 18:24

Re: search for a string in a file
 
use st.Contains

shah123 10Apr2007 18:26

Re: search for a string in a file
 
Shabbir Brother you are the star. Thanks a million

shah123 10Apr2007 18:31

Re: search for a string in a file
 
One more question is

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

Rgds,

shah123 10Apr2007 18:44

Re: search for a string in a file
 
I got the answer for position thanks anyway


All times are GMT +5.5. The time now is 15:32.