69,336
社区成员
发帖
与我相关
我的任务
分享
char buff[8192];
CString strXMLPath, strQueryInfo, strUrl;
strUrl = "http://www.500wan.com/static/info/ssq/project/10056_1_1.txt";
SetConnectTool(strUrl, strXMLPath);
CHttpFile* pHttpFile = m_pHttpConnect->OpenRequest(CHttpConnection::HTTP_VERB_GET, strXMLPath, NULL, 1, NULL, NULL, m_dwHttpRequestFlags);
try
{
if(pHttpFile==NULL||!pHttpFile->SendRequest())
{
pHttpFile->Close();
delete pHttpFile;
return;
}
}catch(...)
{
AfxMessageBox("网络连接异常!");
delete pHttpFile;
return;
}
pHttpFile->QueryInfo(HTTP_QUERY_CONTENT_LENGTH, strQueryInfo);
DWORD dwLen=atol(strQueryInfo);
//从服务器读取文件
int nCount, nRead = 0;
//下载文件
while((nCount=pHttpFile->Read(buff, DOWNLOAD_SPEED))>0)
{
nRead += nCount;
m_strWebContent += buff;
m_strWebContent = m_strWebContent.Left(nRead);
}
pHttpFile->Close();
delete pHttpFile;