16,471
社区成员
发帖
与我相关
我的任务
分享
fileRead.Open(dlg.m_strPath,CFile::typeBinary|CFile::modeRead,NULL);
int length = m_nLength;//读取文件的大小
int iBufSize = 1024*5;//设置文件缓冲区长度
int iSize = iBufSize ; //一次读取的长度
BYTE *pBuf=new BYTE[iBufSize + 1];//定义缓冲区
UINT uiTotal = 0 ;
while( uiTotal < length ){
if( length - uiTotal < iBufSize )//如果发送小于1024*5 ,则发送剩余那些....
iSize = length - uiTotal;
iSize = fileRead.Read(pBuf,iSize);//读取文件到缓冲区
pBuf[iSize] = '\0';
CString sBuf;
sBuf.Format("%s",pBuf);
SendMsgTo(sBuf,5,msg.m_nIndex);//发送剩下iSize-iCount的文件
uiTotal += sBuf.GetLength();//uiTotal总发送量
}
fileRead.Close();
CFile file;
if(file.Open(_T("xxx.zip"),CFile::modeRead|CFile::typeBinary))
{
UINT uiLen = file.GetLength();
BYTE* btFile = new BYTE[uiLen];
if(file.Read(btFile,uiLen) != uiLen)
AfxMessageBox(_T("读取文件出错");
file.Close();
}