C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




TextSearch facility on a Text File


Posted Date: 09 Mar 2007    Resource Type: Code Snippets    Category: File Operations

Posted By: Balamurali Balaji       Member Level: Diamond
Rating:     Points: 10



The following code is used to find a particular text in a text file. It also shows the line number in which the text appears.

								
System.IO.StreamReader sr = new System.IO.StreamReader(@"d:\balamurali\bb.doc");
string content = sr.ReadLine();
int lineno = 1;
while (content != null)
{
if (content.IndexOf("SomeText") > 0)
MessageBox.Show("The specified text found in line no: " + lineno.ToString());
lineno++;
content = sr.ReadLine();
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Create temporary files so that it can be cleaned up automatically
Previous Resource: using IsolatedStorage in your application
Return to Discussion Resource Index
Post New Resource
Category: File Operations


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing

Contact Us    Privacy Policy    Terms Of Use