private bool SendFileToServer(string filePath) { FileInfo fi = new FileInfo(filePath); if (fi.Length > 4096 * 1024) { throw new Exception("被发送文件大小不能超过4096KB。"); } else if (fi.Length == 0) { throw new Exception("文件大小不能为0。"); } // 头附加数据 MyFileInfo myFile = new MyFileInfo() { FilePath = filePath, FileSize = fi.Length, }; // 发送文件标记,用来在onrecv里判断是否文件回包 isSendFile = true; // 不附加尾数据 bool ret = client.SendSmallFile <MyFileInfo, object>(filePath, myFile, null); if (ret == false) { isSendFile = false; int error = client.SYSGetLastError(); AddMsg(string.Format(" > [SendSmallFile] errorCode:{0}", error)); } return(ret); }