The references given by
losmac in Solution 2 are good.
In case if you want to only check whether a word typed in the
TextBox
is present in the text file then I think the
Regex
option is simple to use as shown below
if (Regex.IsMatch(System.IO.File.ReadAllText(textFileName),
string.Format(@"\s+{0}\s+",TextBox1.Text),
RegexOptions.CultureInvariant | RegexOptions.IgnoreCase))
MessageBox.Show("Found");
If you want to match case then remove
| RegexOptions.IgnoreCase
part in the above statement.