1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
int index;
CString strText;
index = m_dir.GetCurSel();
m_dir.GetText(index,strText);
HINTERNET handle1 = FtpOpenFile(hIConnect,strText,GENERIC_READ,FTP_TRANSFER_TYPE_BINARY,0);
DWORD filesized = FtpGetFileSize(handle1,NULL);
CString csNumber;
csNumber.Format("%lu", filesized);
MessageBox(csNumber,csNumber,MB_OK);
HANDLE hFile = CreateFile(strText, GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
char Buffer[4024];
DWORD dwRead =0;
m_yay.SetRange(0,filesized);
while(InternetReadFile(handle1, Buffer, sizeof(Buffer), &dwRead) == TRUE)
{
if ( dwRead == 0)
break;
DWORD dwWrite = 0;
progress2 += dwRead;
m_yay.SetPos(progress2);
WriteFile(hFile, Buffer, dwRead, &dwWrite, NULL);
}
| |