一调试就出问题
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS0117: “System.Net.Sockets.TcpClient”并不包含对“ScriptTimeout”的定义
源错误:
行 51: ASP.WebForm1_aspx.__initialized = true;
行 52: }
行 53: this.Server.ScriptTimeout = 30000000;
行 54: }
行 55:
不知道那位高手能指点一下.
下面是源码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net.Sockets;
using System.IO;
using System.Net;
using System.Web.Mail;
namespace PopClient
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Pwd;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox txtUsername;
protected System.Web.UI.WebControls.Button Button1;
public TcpClient Server;
public NetworkStream NetStrm;
public StreamReader RdStrm;
public string Data;
public byte[] szData;
protected System.Web.UI.WebControls.TextBox PopServer;
protected System.Web.UI.WebControls.TextBox Password;
protected System.Web.UI.WebControls.ListBox Status;
protected System.Web.UI.WebControls.Button Retrieve;
protected System.Web.UI.WebControls.TextBox RichTextBox;
protected System.Web.UI.WebControls.TextBox MailNum;
public string CRLF = "\r\n";
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Retrieve.Click += new System.EventHandler(this.Retrieve_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
//用110端口新建POP3服务器连接
Server = new TcpClient(PopServer.Text,110);
Status.Items.Clear();
try
{
//初始化
NetStrm = Server.GetStream();
RdStrm= new StreamReader(Server.GetStream());
Status.Items.Add(RdStrm.ReadLine());
//登录服务器过程
Data = "USER "+ txtUsername.Text+CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData,0,szData.Length);
Status.Items.Add(RdStrm.ReadLine());
Data = "PASS "+ Password.Text+CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData,0,szData.Length);
Status.Items.Add(RdStrm.ReadLine());
//向服务器发送STAT命令,从而取得邮箱的相关信息:邮件数量和大小
Data = "STAT"+CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData,0,szData.Length);
Status.Items.Add(RdStrm.ReadLine());
}
catch(InvalidOperationException err)
{
Status.Items.Add("Error: "+err.ToString());
}
}
private void Retrieve_Click(object sender, System.EventArgs e)
{
string szTemp;
try
{
//根据邮件编号从服务器获得相应邮件
Data = "RETR "+ MailNum.Text+CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData,0,szData.Length);
szTemp = RdStrm.ReadLine();
if(szTemp[0]!='-')
{
//不断地读取邮件内容,只到结束标志:英文句号
while(szTemp!=".")
{
Retrieve.Text += szTemp;
szTemp = RdStrm.ReadLine();
}
//若BackupChBox未选中,则收取邮件后,删除保留在服务器上的邮件
}
else
{
Status.Items.Add(szTemp);
}
}
catch(InvalidOperationException err)
{
Status.Items.Add("Error: "+err.ToString());
}
}
}
}