/// <summary> /// 加载窗体时就进行监听 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReceiveFileForm_Load(object sender, EventArgs e) { udpReceiveFile = new UdpReceiveFile( int.Parse(localPort)); udpReceiveFile.RequestSendFile += new RequestSendFileEventHandler(RequestSendFile); udpReceiveFile.FileReceiveBuffer += new FileReceiveBufferEventHandler(FileReceiveBuffer); udpReceiveFile.FileReceiveComplete += new FileReceiveEventHandler(FileReceiveComplete); udpReceiveFile.FileReceiveCancel += new FileReceiveEventHandler(FileReceiveCancel); udpReceiveFile.Start(); // AppendLog(string.Format( // "开始侦听,端口:{0}", udpReceiveFile.Port), false); }
private void button1_Click(object sender, EventArgs e) { udpReceiveFile = new UdpReceiveFile( int.Parse(tbLocalPort.Text)); udpReceiveFile.RequestSendFile += new RequestSendFileEventHandler(RequestSendFile); udpReceiveFile.FileReceiveBuffer += new FileReceiveBufferEventHandler(FileReceiveBuffer); udpReceiveFile.FileReceiveComplete += new FileReceiveEventHandler(FileReceiveComplete); udpReceiveFile.FileReceiveCancel += new FileReceiveEventHandler(FileReceiveCancel); udpReceiveFile.Start(); AppendLog(string.Format( "开始侦听,端口:{0}", udpReceiveFile.Port), false); }