Solution 1 which i provide was an idea you need to use it with little modication. You claim that that is not working but not provide detail error information which you found. However i will provide full code which i tested and found working with .NET framework 4.5 with Windows forms application.
I just add a sample WOrdFile.txt file in my solution with line break of every word.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private IEnumerable<string> _wordList;
public Form1()
{
InitializeComponent();
PopulateWordList();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
string searchWord = textBox1.Text;
IEnumerable<string> result = _wordList.Where(d => d.StartsWith(searchWord));
foreach (string word in result)
{
listBox1.Items.Add(word);
}
}
private void PopulateWordList()
{
string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) , "WOrdFile.txt");
if (File.Exists(filePath))
{
_wordList = File.ReadLines(filePath);
}
}
}
}
I created a Windows Form app and a new windows form there i put one textbox, one listbox and one button. The code is self explanatory. Let me know anything you do not understand in code.