这是发送文件代码
void CMyDlg::OnButton1() 
{
FILE *pf;
   extern bool tg;
tg=true;
CByteArray sendData; 
   int line=0;
 int i=0;
 long int Filelth;
 sendData.SetSize(17);
    BYTE* sendArr = new BYTE[17];
CFileDialog Dlg(true);
    Dlg.m_ofn.lpstrFilter="Txt File(*.dat)\0*.dat\0All File(*.*)\0*.*\0\0";
CString fnamee;
if(IDOK==Dlg.DoModal())

fnamee=Dlg.GetPathName();
fnamee.Replace("\\","\\\\");
CFile FileDlg(Dlg.GetFileName(), CFile::modeRead );
  Filelth=FileDlg.GetLength();
  FileDlg.Close();
}
  pf=fopen(fnamee,"r+b");
  CString cs;
  cs.Format("%d",Filelth);
  AfxMessageBox(cs);
while(line*16<Filelth)
{   if(line*16+16<=Filelth)
{
fseek(pf,line*16,0);
for(int ii=0;ii<16;ii++)
fread(&sendArr[ii],1,1,pf);
for(int j =0; j<16; j++)
{
      sendData.SetAt(j, sendArr[j]);
}
m_mscomm1.SetOutput(COleVariant(sendData));
CString bb;
}
else
{
i=Filelth%16;
fseek(pf,line*16,0);
for(int ii=0;ii<i;ii++)
fread(&sendArr[ii],1,1,pf);
for(int j =0; j<i; j++)
{
 sendData.SetAt(j, sendArr[j]);
}
m_mscomm1.SetOutput(COleVariant(sendData));
}
line++;}
delete sendArr;
if(Filelth==(line-1)*16+i)
AfxMessageBox("发送完毕"); 
fclose(pf);
}