/// <summary> /// 发送文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { switch (button3.Text) { case "发送文件": try { int fileLabel = 0; if (checkBox1.Checked) { fileLabel = udptx.SendFile(UdpIPEndPoint, this.textBox4.Text); } else { fileLabel = TxClient.SendFile(this.textBox4.Text); } label6.Text = fileLabel.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } break; case "暂停发送": try { FileSend.FileStop(int.Parse(label6.Text)); button3.Text = "文件续传"; } catch (Exception ex) { MessageBox.Show(ex.Message); } break; case "文件续传": try { if (checkBox1.Checked) { udptx.ContinueFile(UdpIPEndPoint, int.Parse(label6.Text)); } else { TxClient.ContinueFile(int.Parse(label6.Text)); } } catch (Exception ex) { MessageBox.Show(ex.Message); } break; } }
/// <summary> /// 文件操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button5_Click(object sender, EventArgs e) { switch (button5.Text) { case "暂停接收": try { FileReceive.FileStop(int.Parse(label6.Text)); button5.Text = "文件续传"; } catch (Exception ex) { MessageBox.Show(ex.Message); } break; case "文件续传": try { if (checkBox1.Checked) { udptx.ContinueFile(UdpIPEndPoint, int.Parse(label6.Text)); } else { IPEndPoint client = (IPEndPoint)this.comboBox1.SelectedItem; if (client == null) { MessageBox.Show("没有选中任何在线客户端!"); return; } if (!this.server.clientCheck(client)) { MessageBox.Show("目标客户端不在线!"); return; } server.ContinueFile(client, int.Parse(label6.Text)); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } break; } }