void DownloadHelper(ChainClient client, ChainPackage chainPackage, string saveFilePath, bool isCreate = true) { Client = client; FileStream = new FileStream(saveFilePath, FileMode.OpenOrCreate); Client.OnReceived += Client_OnReceived; Client.Send(chainPackage); }
void UploadHelper(ChainClient client, ChainPackage chainPackage, string saveFilePath) { #region 向监控发送实时文件 byte[] buff = new byte[800 * 1024]; using (FileStream fs = File.OpenRead(saveFilePath)) { BinaryReader binaryReader = new BinaryReader(fs); int count = binaryReader.Read(buff, 0, buff.Length); while (count > 0) { byte[] t_data = new byte[count]; Buffer.BlockCopy(buff, 0, t_data, 0, count); ChainPackage cp = new ChainPackage(t_data); cp.Header.Data.Clear(); cp.Header.Data.Add(chainPackage.Header.Data); cp.Header.Data[HeadKeys.ContentLen] = t_data.Length.ToString(); cp.Header.Data.Add(HeadKeys.FileLength, fs.Length.ToString()); client.Send(cp, false); buff = new byte[800 * 1024]; count = binaryReader.Read(buff, 0, buff.Length); } } #endregion }