Ejemplo n.º 1
0
 /// <summary>
 /// 读取文件方法
 /// </summary>
 /// <param name="e"></param>
 protected void OnReadFileBuffer(ReadFileBufferEventArgs e)
 {
     if (ReadFileBuffer != null)
     {
         ReadFileBuffer(this, e);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 结束读取文件
        /// </summary>
        /// <param name="result"></param>
        private void EndRead(IAsyncResult result)
        {
            if (FileStream == null)
            {
                return;
            }
            int            length = FileStream.EndRead(result);
            ReadFileObject state  = (ReadFileObject)result.AsyncState;
            int            index  = state.Index;

            byte[] buffer             = state.Buffer;
            ReadFileBufferEventArgs e = null;

            if (length < _partSize)
            {
                byte[] realBuffer = new byte[length];
                Buffer.BlockCopy(buffer, 0, realBuffer, 0, length);
                e = new ReadFileBufferEventArgs(index, realBuffer);
            }
            else
            {
                e = new ReadFileBufferEventArgs(index, buffer);
            }
            OnReadFileBuffer(e);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 读取文件并发送文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendFileManageReadFileBuffer(
            object sender, ReadFileBufferEventArgs e)
        {
            SendFileManager  sendFileManager = sender as SendFileManager;
            TraFransfersFile ts = new TraFransfersFile(
                sendFileManager.MD5, e.Index, e.Buffer);

            Send((int)Command.RequestSendFilePack, ts);
        }