Exemplo n.º 1
0
       /// <summary>
       /// 初始化socket,并开始发送
       /// </summary>
       /// <param name="endpoint"></param>
        public void BeginSendFile(MyEndPoint endpoint)
        {
           
                fm.EndPoint = endpoint;
                transferFileUtil = new SendFileUtil(fm, this);

              
            
           
        }
Exemplo n.º 2
0
       /// <summary>
       /// 保存按钮按下事件
       /// </summary>
       /// <param name="sender"></param>
       /// <param name="e"></param>
        void saveBorder_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ///隐藏另存为按钮,把另外一个按钮文字设为取消接收
            saveBorder.Visibility = Visibility.Hidden;
            cancleBtn.Text = "取消";
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.FileName = fm.FileName;
            ///忘了是什么Bug了
            sfd.RestoreDirectory = true;
            sfd.ShowDialog();
          
            fm.Path = sfd.FileName;
            fm.Path = fm.Path.Remove(fm.Path.LastIndexOf(sfd.SafeFileName));
            fm.Path = fm.Path + fm.Guid;
            fm.FileName = sfd.SafeFileName;
            transferFileUtil = new ReceiveFileUtil(fm, this);

           ///初始化接收端口并
            ((ReceiveFileUtil)transferFileUtil).initTcpHost();
           

            ///开始等待接收
         //   transferFileUtil.Transfer();

            ///通知发送端,告知自己的端口。
            ///目前无法实现非局域网tcp打洞
            DataUtil.Client.ResponseToRequest(new Result()
            {
                Member = fm.from as Member,
                Status = MessageStatus.Accept,
                Type = MessageType.File,
                EndPoint = new MyEndPoint() { Address = fm.EndPoint.Address, Port = fm.EndPoint.Port },
                Guid=fm.Guid
            });
            
            

                   
            }