//发送目录请求包
intReturn = send(((CFtpClientApp*)AfxGetApp())->FtpClientSocket,(char*)myFtpControl,sizeof(FtpControl),0); if(SOCKET_ERROR == intReturn)
{
LpStateInfo->strInfo = "发送目录请求失败!";
////////////////////////////Client//////////////////////////////////
::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightBottomView->m_hWnd,UM_OUT_PUT_RESULT,NULL,(LPARAM)LpStateInfo);
}else
{
AfxMessageBox("TEST!"); FTP_FILE_LIST_PACK *LpFile_List = new FTP_FILE_LIST_PACK;
//接收文件列表包
recv(((CFtpClientApp*)AfxGetApp())->FtpClientSocket,(char*)LpFile_List,sizeof(FTP_FILE_LIST_PACK),0);
//AfxMessageBox(LpFile_List->Buf);
//在右边列表视图中显视
::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightListView->m_hWnd,UM_RIGHT_SERVER_LIST,NULL,(LPARAM)LpFile_List);
delete[] (char*)LpFile_List; LpStateInfo->strInfo = "目录请求成功!";
::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightBottomView->m_hWnd,UM_OUT_PUT_RESULT,NULL,(LPARAM)LpStateInfo);
}
//////////////////////////////Server////////////////////////////
AfxMessageBox(FtpCtrl->bufData);
//根据用户名列出目录
CString strFileName,strFileSize,strFileTime; FTP_FILE_LIST_PACK *myFileList = new FTP_FILE_LIST_PACK; myDataOption.EnumerateDirectoryDetail(strFileName,strFileSize,strFileTime,FtpCtrl->bufData);
myDataOption.EnumerateFilesDetail(strFileName,strFileSize,strFileTime,FtpCtrl->bufData); //文件名列表
memcpy(myFileList->Buf,strFileName.GetBuffer(0),strFileName.GetLength());
memcpy(myFileList->FileSize,strFileSize.GetBuffer(0),strFileSize.GetLength());
memcpy(myFileList->FileTime,strFileTime.GetBuffer(0),strFileTime.GetLength());
myFileList->Buf[strFileName.GetLength()] = '\0';
myFileList->FileSize[strFileTime.GetLength()] = '\0';
myFileList->FileTime[strFileTime.GetLength()] = '\0';
myFileList->intLength = FILE_CONTENT_SIZE;
//AfxMessageBox(FileList->Buf);
//响应客户端的目录请求
send(mySocket,(char*)myFileList,sizeof(FTP_FILE_LIST_PACK),0);
//AfxMessageBox(FileList->Buf);
delete[] (char*)myFileList;
intReturn = send(((CFtpClientApp*)AfxGetApp())->FtpClientSocket,(char*)myFtpControl,sizeof(FtpControl),0); if(SOCKET_ERROR == intReturn)
{
LpStateInfo->strInfo = "发送目录请求失败!";
////////////////////////////Client//////////////////////////////////
::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightBottomView->m_hWnd,UM_OUT_PUT_RESULT,NULL,(LPARAM)LpStateInfo);
}else
{
AfxMessageBox("TEST!"); FTP_FILE_LIST_PACK *LpFile_List = new FTP_FILE_LIST_PACK;
//接收文件列表包
recv(((CFtpClientApp*)AfxGetApp())->FtpClientSocket,(char*)LpFile_List,sizeof(FTP_FILE_LIST_PACK),0);
//AfxMessageBox(LpFile_List->Buf);
//在右边列表视图中显视
::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightListView->m_hWnd,UM_RIGHT_SERVER_LIST,NULL,(LPARAM)LpFile_List);
delete[] (char*)LpFile_List; LpStateInfo->strInfo = "目录请求成功!";
::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightBottomView->m_hWnd,UM_OUT_PUT_RESULT,NULL,(LPARAM)LpStateInfo);
}
//////////////////////////////Server////////////////////////////
AfxMessageBox(FtpCtrl->bufData);
//根据用户名列出目录
CString strFileName,strFileSize,strFileTime; FTP_FILE_LIST_PACK *myFileList = new FTP_FILE_LIST_PACK; myDataOption.EnumerateDirectoryDetail(strFileName,strFileSize,strFileTime,FtpCtrl->bufData);
myDataOption.EnumerateFilesDetail(strFileName,strFileSize,strFileTime,FtpCtrl->bufData); //文件名列表
memcpy(myFileList->Buf,strFileName.GetBuffer(0),strFileName.GetLength());
memcpy(myFileList->FileSize,strFileSize.GetBuffer(0),strFileSize.GetLength());
memcpy(myFileList->FileTime,strFileTime.GetBuffer(0),strFileTime.GetLength());
myFileList->Buf[strFileName.GetLength()] = '\0';
myFileList->FileSize[strFileTime.GetLength()] = '\0';
myFileList->FileTime[strFileTime.GetLength()] = '\0';
myFileList->intLength = FILE_CONTENT_SIZE;
//AfxMessageBox(FileList->Buf);
//响应客户端的目录请求
send(mySocket,(char*)myFileList,sizeof(FTP_FILE_LIST_PACK),0);
//AfxMessageBox(FileList->Buf);
delete[] (char*)myFileList;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货