473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

code here

here is the code which looking for a folder and search some strings
which
are taken from a database called as marka[] a want to search those
string
very as possible which thread
thanks
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Text;
using System.Data.OleDb;
using System.Text.RegularExpressions;
namespace Spider
{
/// <summary>
/// Summary description for Stringara.
/// </summary>
public class Stringara
{

private Hashtable m_file=new Hashtable();

/// <summary>
/// URL's that are waiting to be processed.
/// </summary>
private SpiderForm m_spiderForm;
private Queue m_workload=new Queue();
private Thread m_thread1;
enum Status { STATUS_FAILED, STATUS_SUCCESS,
STATUS_QUEUED };
private bool m_quit;
private Spider m_spider1;
String[] marka=new string[1500];
ArrayList flist=new ArrayList();
public void reset()
{
m_file = new Hashtable();
m_workload = new Queue();
m_quit = false;
}

public bool Quit
{
get
{
return m_quit;
}

set
{
m_quit = value;
}
}

public void folderlist()
{
string fldr=@"C:\temp\rt";
//System.Windows.Forms.MessageBox.Show(fldr);
DirectoryInfo dir = new DirectoryInfo(fldr);
FileInfo[] files = dir.GetFiles("*.html");
string fnm;
foreach(FileInfo fi in files)
{
//flist.Add(fi.Name);
fnm=fi.Name;

m_file.Add(fnm.ToString(),Status.STATUS_QUEUED);

//System.Windows.Forms.MessageBox.Show(fi.Name);
m_workload.Enqueue(fnm);
}

}
//public Queue marka=new Queue();

public void keyword()
{
string str="Provider =Microsoft.Jet.OLEDB.4.0 ;
Data
Source=..\\..\\Employee.mdb";
string cmd = "SELECT Keyword from KeyQ" ;
OleDbConnection con = new OleDbConnection ( str
) ;
OleDbCommand com = new OleDbCommand ( cmd, con )
;
con.Open();
int i=0;
OleDbDataReader r = com.ExecuteReader ( ) ;
while ( r.Read ( ) )
{
marka[i]=r[0].ToString();
i++;
}

con.Close ( ) ;
}

public void Start(int threads)
{

folderlist();
//reset();
keyword();

for(int i=1;i<threads;i++)
{
ThreadStart ts = new
ThreadStart( this.find);
m_thread1= new Thread(ts);

//m_thread.Priority=ThreadPriority.Highest;
m_thread1.Start();
}
}
public void find()
{
int m_threadCount=1;

while(m_threadCount<m_workload.Count)
{

//Monitor.Enter(this.m_thread1);
//Monitor.Pulse(this.m_thread1) ;
string str="";
string line=null;
string
str1=@"C:\temp\rt\"+m_workload.Dequeue().ToString( );
string path = @"C:\Documents and
Settings\Rustem\Desktop\csspider\csspider\keyword. txt";

//string lPattern = "(tayyip|erdoğan)";

StreamReader sr =new
StreamReader(str1,System.Text.Encoding.GetEncoding ("windows-1254"));

while ((line = sr.ReadLine()) != null)
{
str+=line+"\r\n";
}
//System.Windows.Forms.MessageBox.Show(str1);
string lPattern1 = ">(?:(?<c>[^<]+))";
Regex rx = new Regex(lPattern1,
RegexOptions.IgnoreCase |
RegexOptions.Compiled );
StringBuilder sb = new StringBuilder();
Match mt;

for ( mt = rx.Match(str); mt.Success; mt
= mt.NextMatch() )
{
sb.Append(
mt.Groups["c"].ToString() );
sb.Append( " " );

}
string spure=sb.ToString();

for (int i = 0; i <=1000; i++)
{

string
lPattern="("+marka[i].ToString()+")";
RegexOptions ro = new
RegexOptions();
ro = ro |
RegexOptions.IgnoreCase;
ro = ro |
RegexOptions.Multiline;
Regex re = null;
MatchCollection mc = null;
re = new Regex(lPattern, ro);
mc = re.Matches(spure);
if (mc.Count>0)
{

using (StreamWriter sw =
File.AppendText(path))
{

// Add some text
to the file.

sw.WriteLine(str1);

sw.WriteLine(mc.Count.ToString());

sw.WriteLine(marka[i].ToString());
}
}
//System.Windows.Forms.MessageBox.Show(mc.Count.ToSt ring());
}
m_threadCount++;
}
}

}
}>
Nov 16 '05 #1
0 944

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
15
by: Ralf W. Grosse-Kunstleve | last post by:
****************************************************************************** This posting is also available in HTML format: http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html...
4
by: Rob Conner | last post by:
No you don't need to know Zope to help me. The whole reason I'd even want to do this is because of Zope though. I made a Zope product, and now want to perfect it. some simple example code... ...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
8
by: ben | last post by:
i have a bit of code, that works absolutely fine as is, but seems over complicated/long winded. is there anyway to shorten/simplify it? the code is below. description of it: it's like strcpy in...
192
by: Vortex Soft | last post by:
http://www.junglecreatures.com/ Try it and tell me what's happenning in the Microsoft Corporation. Notes: VB, C# are CLS compliant
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
22
by: Colin McGuire | last post by:
I apologize for posting yet another scrollbar question. Here is my code. All I want is for a diagonal line to appear from coordinates (0,0) to (width,height) in a usercontrol regardless of whether...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.