Поиск слов в документах. Проверка что ничего не найдено. - C#
Формулировка задачи:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
string fold = textBox1.Text;
string[] files = Directory.GetFiles(fold);
string sl = textBox2.Text;
for (int i = 0; i < files.Length; i++)
{
string s = File.ReadAllText(files[i]);
if (s.IndexOf(sl) != -1)
{
string pos = s.IndexOf(s).ToString();
listBox1.Items.Add("\n" + files[i]);
}
}
}
}
}
Будьте добры помогите плиз Срочно нужно на завтра доделать программу.
Решение задачи: «Поиск слов в документах. Проверка что ничего не найдено.»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
string fold = textBox1.Text;
string[] files = Directory.GetFiles(fold);
string sl = textBox2.Text;
for (int i = 0; i < files.Length; i++)
{
string s = File.ReadAllText(files[i]);
if (s.IndexOf(sl) != -1)
{
string pos = s.IndexOf(s).ToString();
listBox1.Items.Add("\n" + files[i]);
}
else
MessageBox.Show("Не найдено!");
}
}
}
}