我的程序是这样写得,你们看看对不对。
CInternetSession netSession;
CStdioFile *fTargetFile;
char strbuf[512];
int bytesread=0;
fTargetFile=netSession.OpenURL("XXXXX.jpg",1,INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
CString szDestPath ="E:\\";
szDestPath+=fTargetFile->GetFileName();
CFile fDestFile(szDestPath,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
while(bytesread=fTargetFile->Read(strbuf,1024))
{
fDestFile.Write(strbuf,bytesread);
}
CInternetSession netSession;
CStdioFile *fTargetFile;
char strbuf[512];
int bytesread=0;
fTargetFile=netSession.OpenURL("XXXXX.jpg",1,INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
CString szDestPath ="E:\\";
szDestPath+=fTargetFile->GetFileName();
CFile fDestFile(szDestPath,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
while(bytesread=fTargetFile->Read(strbuf,1024))
{
fDestFile.Write(strbuf,bytesread);
}
解决方案 »
- VC实现从当前日期减去一个特定的天数是哪年哪月哪日?
- 如何限制窗口最大化//不超过1920?
- [mshtml]如何点击掉alert弹出框?(除了FindWindow+PostMessage)
- 请问在VC.net中菜单已生成了一个消息响应函数,比如afx_msg void OnAppEdit(),其参数是空的,我现想增加一个CString参数,应该如何写?
- 请教CFtpConnection类变量m_connection的传递问题
- 打印问题,不使用mfc框架和文档视图支持
- 编一个DLL给VB用,需要传递一个大数组A[2][100]怎样处理。谢谢!
- vc如何动态加载access数据库文件
- 请问哪里有下载《VC技术内幕的》呀
- ???用HtmlView打开html后,如何捕捉滚动条消息???
- 如何让启用线程的窗口为前端活动窗口
- 过来人指点一下
CInternetSession sess;
CString strURL = "http://www.baidu.com/img/baidu_logo.gif";
CHttpFile* pFile=(CHttpFile*)sess.OpenURL(strURL,1,INTERNET_FLAG_TRANSFER_BINARY);
BYTE *buffer = new BYTE[10240]; FILE *file;
file = fopen("D:\\baidu_logo.gif ","wb");
int nRead = 0;
while(nRead = pFile->Read(buffer, 10240))
{
fwrite(buffer, 1, nRead, file);
memset(buffer, 0, 10240); }
fclose(file);
delete buffer;