PDA

View Full Version : سوال: جستجو گر متن



abasfar
شنبه 30 بهمن 1389, 16:43 عصر
سلام کسی میدونه چه چوری میشه از یک جستجو گر متن بدون محدودیت جستجو یا تعداد برگشتی جستجو در C# ساخت یا استفاده کرد ممنون میشم جواب بدهید

shytonak
شنبه 30 بهمن 1389, 21:14 عصر
با این کد می تونید تمام فایل های متنی رو باز کنی و درونش جستجوکنی


foreach (string strfolder in System.IO.Directory.GetFiles(Environment.CurrentDi rectory+"آدرس فولدر"))

{

string fName = strfolder; //path to text file

StreamReader testTxt = new StreamReader(fName);

string allRead = testTxt.ReadToEnd();//Reads the whole text file to the end

testTxt.Close();//Closes the text file after it is fully read.

string regMatch = textBox3.Text; //string to search for inside of text file. It is case sensitive.

if (Regex.IsMatch(allRead, regMatch) & textBox3.Text != "")//If the match is found in allRead

{

listBox1.Items.Add(strfolder);

}

abasfar
شنبه 30 بهمن 1389, 23:12 عصر
ممنون فقط منضور من جستجو در اینترنت بود نه فایلی ونه پایگاه داده شرمنده که روی سوال را ناقص نوشتم چیزی مثل Search Engine اما اسون تر و قابل درک تر بازم ممنون