View Full Version : سوال: جستجو گر متن
abasfar
شنبه 30 بهمن 1389, 17:43 عصر
سلام کسی میدونه چه چوری میشه از یک جستجو گر متن بدون محدودیت جستجو یا تعداد برگشتی جستجو در C# ساخت یا استفاده کرد ممنون میشم جواب بدهید
shytonak
شنبه 30 بهمن 1389, 22: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
یک شنبه 01 اسفند 1389, 00:12 صبح
ممنون فقط منضور من جستجو در اینترنت بود نه فایلی ونه پایگاه داده شرمنده که روی سوال را ناقص نوشتم چیزی مثل Search Engine اما اسون تر و قابل درک تر بازم ممنون
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.