内容存放在名为20060813_WEB_000.w3c的文件中,可以用记事本打开,其中格式如下:
#Software: Microsoft Internet Security and Acceleration Server 2004
#Version: 2.0
#Date: 2006-08-13 00:00:12
#Fields: c-ip date time cs-protocol cs-uri
172.16.102.13 2006-08-13 00:00:12 http http://c.msn.com/c.gif?di=4988
172.16.102.13 2006-08-13 00:00:26 http http://72.36.164.90/svc/?172.16.100.38 2006-08-13 00:00:49 http http://218.30.15.18/i_p.jpg
172.16.100.49 2006-08-13 00:01:26 http http://218.30.15.18/i_p.jpg
..............现在要求根据输入IP和时间段把相应的记录查询出来并显示在页面上,请问各位大侠该如何实现,给个思路,多谢了!
如果查询IP=172.16.102.13 在00:00:00-01:00:00之间的记录,显示结果为
c-ip date time cs-protocol cs-uri
172.16.102.13 2006-08-13 00:00:12 http http://c.msn.com/c.gif?di=4988
172.16.102.13 2006-08-13 00:00:26 http http://72.36.164.90/svc/?
#Software: Microsoft Internet Security and Acceleration Server 2004
#Version: 2.0
#Date: 2006-08-13 00:00:12
#Fields: c-ip date time cs-protocol cs-uri
172.16.102.13 2006-08-13 00:00:12 http http://c.msn.com/c.gif?di=4988
172.16.102.13 2006-08-13 00:00:26 http http://72.36.164.90/svc/?172.16.100.38 2006-08-13 00:00:49 http http://218.30.15.18/i_p.jpg
172.16.100.49 2006-08-13 00:01:26 http http://218.30.15.18/i_p.jpg
..............现在要求根据输入IP和时间段把相应的记录查询出来并显示在页面上,请问各位大侠该如何实现,给个思路,多谢了!
如果查询IP=172.16.102.13 在00:00:00-01:00:00之间的记录,显示结果为
c-ip date time cs-protocol cs-uri
172.16.102.13 2006-08-13 00:00:12 http http://c.msn.com/c.gif?di=4988
172.16.102.13 2006-08-13 00:00:26 http http://72.36.164.90/svc/?
你用textreader来一行行读取,格式固定,分别取出ip,datetime,url三部分,然后存入Datatable中。以后查找可以用DataTable.Select来完成。
一行一行读去进行处理
string line = "";
while ((line = sr.ReadLine()) != null)
{
//处理一行。
Console.WriteLine(line);
}
using (StreamReader sr = new StreamReader(FilePath))
{
String line;
while (sr.Peek() != -1)
{
line = sr.ReadLine();
}}
再对每一行的记录进行判断处理
好像50m的要10来分钟。
select * from openrowset('MICROSOFT.JET.OLEDB.4.0','Text;HDR=Yes;DATABASE=c:\',a#txt)a.txt
aa;5512,332;01.010.03
bb;45,6125;02.01.04Schema.ini
[a.txt]
ColNameHeader=false
format=Delimited(;)
DatetimeFormat=DD.MM.YY
DecimalSymbol=,
col1=Name Text WIDTH 10
col2=Num Currency
col3=Date Date
/*
Date Name Num
------------------------------------------------------ ---------- ---------------------
2003-10-01 00:00:00.000 aa 5512.3320
2004-01-02 00:00:00.000 bb 45.6125
*/