Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sir i am doing a project of my own.in that i want if a entered a text in textbox it should be check against a list of words in the notepad.my quaries are.
1)how to attach a notepad to our project.
2)how to check the word against the list of words in the note pad.
please help sir.
Posted
Comments
Sergey Alexandrovich Kryukov 25-Feb-15 14:09pm    
What do you mean "in the notepad". Want to break into a foreign process? Bad idea... :-)
Do something reasonable instead.
—SA

You can attach the text file to the project just by dragging it into the Visual studio solution explorer.

In order to read the content of the file you can use File.ReadLines[^] method. That would get you a list of string that you can use for matching the data in the textbox
 
Share this answer
 
Comments
Member 11460134 25-Feb-15 16:00pm    
can u post the code..by taking a sample text box and notepad....
You can't (or at least you really, really shouldn't) be trying to use an external EXE as a "editing box" in app - you should instead consider either using a TextBox or RichTextBox control embedded into your application.
That way, you can access it's text content with no problems at all - it's just a property of the control - and you don't have to rely on your user using notepad (or even having it installed - it's not difficult to replace with something better that works very, very differently as far as your application would be concerned.
 
Share this answer
 
C#
//This code first read the words in text file one by one,
//which are save in notepad file like one word per line

int aCounter = 0; string aWordInTextFile;
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader("c:\notePadFile.txt");
while((aWordInTextFile = file.ReadLine()) != null){
   Console.WriteLine (aWordInTextFile);
   if(textbox.text == aWordInTextFile){
        messagebox.show("String Match, found a string in notepad file");
   }
   aCounter++;

}

file.Close();

// Suspend the screen.
Console.ReadLine();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900