protected void Button1_Click(object sender, EventArgs e)
{
HttpFileCollection fc = Request.Files;
HttpPostedFile pf = fc[0];
if (pf.ContentLength > 0)
{
//string split = TextBox1.Text;
int sum = 0;
StringBuilder sb = new StringBuilder();
StreamReader sr = new StreamReader(pf.InputStream, Encoding.Default);
while (!sr.EndOfStream)
{
string sa = sr.ReadLine();
sb.Append(sa);
//sb.Append(";");
if (iptolong("58.18.40.1") <= iptolong(sa) && iptolong(sa) <= iptolong("58.18.40.254"))
{
sum++;
}
sb.Append("<br>");
}
Response.Write("SUM:" + sum + "<br>");
Response.Write(sb.ToString());
}
}
因为我的.txt文件是一个IP列表这里的方法iptolong是上篇blog中写到的方法