Click here to Skip to main content
14,699,107 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Friends,

I have an textbox and an search button when i am click on search button its match the textbox text in text file and if text is match then its show next word in the messagebox or label.

how i can do this thing?

right now i am using the follwing code which is help to match the textbox value in the textfield but how i can got the next word form the text file can any one help me??

Dim InputStr As String = SearchTextbox.Text
       For Each FileStr As String In IO.Directory.GetFiles("D:\", "*.txt")
           If IO.File.ReadAllText(FileStr).IndexOf(InputStr) >= 0 Then


               'SearchTextbox.Text = IO.File.ReadAllText(InputStr)

               MessageBox.Show("Text Match Dome.", "Text Match", MessageBoxButton.OK, MessageBoxImage.Information)
           End If
       Next
Posted
Comments
Sergey Alexandrovich Kryukov 27-Sep-12 13:12pm
   
How on Earth this can be related to WPF?
--SA
Sergey Alexandrovich Kryukov 27-Sep-12 13:16pm
   
And what did you try? What you show is pretty unrelated to the problem, as well as WPF. You are not even trying to analyze the result it ReadAllText...
--SA

Without your if operator, assign the result of ReadAllText to some string variable and parse it to get what you need. Start with System.String.Split:
http://msdn.microsoft.com/en-us/library/system.string.split.aspx[^].

—SA
   
Here is the code that i used..

Dim fileAs String = Application.StartupPath & "\file.txt"

      If System.IO.File.Exists(file.txt) = True Then
          Dim objReader As New System.IO.StreamReader(file.txt)
          file= objReader.ReadToEnd

         ' Or you can use objReader.ReadLine '
      Else
          MsgBox("File does not exists")
          Exit Sub
      End If
   
v2

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