hey guys. i get an error "Could not find a part of the path" for inputStream = File.OpenText(textBox1.Text).
The idea is to enter a folders path then in another textbox enter word to search.
all the files in the folder have to be searched then the word,filename and path are strung into texbox2.
any ideas at what to do || what im doing wrong? Thanks heaps
private void searchbutton_Click(object sender, EventArgs e)
{
String Word;
string[] words = new string[3];
char []seperator = {','};
bool found = false;
StreamReader inputStream;
if (inputtextBox.Text == "")
{
MessageBox.Show("Please enter something to search in files", "Error");
inputtextBox.Focus();
}
else
try
{
string[] directories = Directory.GetDirectories(textBox1.Text);
string[] files = Directory.GetFiles(textBox1.Text);
inputStream = File.OpenText(textBox1.Text);//* error comes in here*\\
Word = inputStream.ReadLine();
while ((Word != null) && found == false)
{
words = Word.Split(seperator);
if (words[0].Trim() == inputtextBox.Text)
{
textBox2.Text = words[1].Trim();
textBox2.Text = words[2].Trim();
found = true;
}
}
inputStream.Close();
for (int i = 0; i < files.Length; i++)
{
if (files[i].Contains(inputtextBox.Text))
textBox2.Text += files[i].Substring(files[i].LastIndexOf('\\') + 1) + "\t" + files [i] + "\n";
}