The TextSearch-1.0reveals the track to enhance the search functionality of Text Documents(s) belongs to same path/folder.
TextSearch-1.0, allows user to search a specific word from many text documents (File Format: *.txt)that belongs to same directory, with no need to open individual file(s) to search a word/text. It has simple GUI.
About Classes used –
#1: FolderBrowserDialog class allows user to select a folder.
#2: Directoryclass allows user to enumerate the file(s) available at specified directory path.
#3: StreamReader class provides an access to read the data from Stream such as Text File.
#4: Processclass, to allow user to start a specific process.
Controls Used –
1. TextBox Control (txtFolder, txtSearch)
2. ListBox Control (lbFiles)
2. Button Control (btnFolder, btnSearch, btnReset)
Here I present a Code for finding a text file(s) with a specified word/text provided as search string.
1. Variable Declarations
2. List All Text File(s) (File Format: *.txt)
3. After Click the “Folder” button, assign the selected path from to txtFolder TextBox, & call the getFiles()method to list all files within that folder.
4. List All Text File(s) which includes a string to be search.
5. Call a Search() method to list a resultant text file(s) at an OnClick Event of “Search”button.
6. Now execute the Application & see the intended result (Figure 1 & 2).
- TextSearch-1.0, allow to regain a list of initial text files as before search (“Reset Search”).
- User can open a file, by double clicking the file name.
The Program TextSearch-1.0 is written is Visual C#, which allows a user to search a text file(s) which includes a specified word/text.