private void button1_Click(object sender, EventArgs e) { if (this.cmbCon.SelectedItem != null) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { try { int t = ofd.FileName.LastIndexOf("."); int m = ofd.FileName.LastIndexOf("\\"); string str = ofd.FileName.Replace(ofd.FileName.Substring(m, t - m), "\\" + idlist[this.cmbCon.SelectedIndex]); if (File.Exists(ofd.FileName)) { File.Move(ofd.FileName, str); ofd.FileName = str; } SendFileManager sendFileManager = new SendFileManager( ofd.FileName); if (udpSendFile.CanSend(sendFileManager)) { FileTransfersItem item = fileTansfersContainer.AddItem( sendFileManager.MD5, "发送文件", sendFileManager.Name, Icon.ExtractAssociatedIcon(ofd.FileName).ToBitmap(), sendFileManager.Length, FileTransfersItemStyle.Send); item.CancelButtonClick += new EventHandler(ItemCancelButtonClick); item.Tag = sendFileManager; sendFileManager.Tag = item; udpSendFile.SendFile(sendFileManager, item.Image); } else { MessageBox.Show("文件正在发送,不能发送重复的文件。"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else { MessageBox.Show("您没有作为记录人参加的会议,无法上传资料!"); } }
private void button1_Click( object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { try { SendFileManager sendFileManager = new SendFileManager( ofd.FileName); if (udpSendFile.CanSend(sendFileManager)) { FileTransfersItem item = fileTansfersContainer.AddItem( sendFileManager.MD5, "发送文件", sendFileManager.Name, Icon.ExtractAssociatedIcon(ofd.FileName).ToBitmap(), sendFileManager.Length, FileTransfersItemStyle.Send); item.CancelButtonClick += new EventHandler(ItemCancelButtonClick); item.Tag = sendFileManager; sendFileManager.Tag = item; udpSendFile.SendFile(sendFileManager, item.Image); } else { MessageBox.Show("文件正在发送,不能发送重复的文件。"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }