posts - 13,comments - 0,trackbacks - 0

 

BOOL Download( CString szURL, CString szDstFile )
{
	BOOL res = false;
	CInternetSession Session;
	CHttpFile *pHttpFile = NULL;

	try{
		pHttpFile = (CHttpFile*)Session.OpenURL(szURL);
	}catch(CInternetException * m_pException){
		pHttpFile = NULL;
		m_pException->m_dwError;
		m_pException->Delete();
		Session.Close();
		res = false;
	}

	CString strLine;
	CFile xmlFile;
	BOOL bResult = xmlFile.Open(szDstFile, CFile::modeCreate | CFile::modeWrite);
	if(pHttpFile != NULL && bResult)
	{
		while(pHttpFile->ReadString(strLine) != NULL)
		{
			xmlFile.Write(strLine, strLine.GetLength());
		}
		xmlFile.Close();
		res = true;
	}
	else
	{
		res = false;
	}

	Session.Close();
	pHttpFile->Close();
	delete pHttpFile;
	pHttpFile = NULL;
	
	return res;
}
 
posted on 2011-08-31 16:35 CrackRen 阅读(131) 评论(0)  编辑  收藏 所属分类: VC

只有注册用户登录后才能发表评论。


网站导航: