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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
UpdateData(TRUE);
CInternetSession m_pInetSession("FTP");
CFtpConnection *m_pFtpConnection;
m_pFtpConnection = m_pInetSession.GetFtpConnection(m_url,m_login,m_mdp,21);
m_progress.SetPos(0);
CString sTemp;
CFile file;
file.Open(m_fichier_path, CFile::modeRead, NULL);
[u]CInternetFile *pInternetFile=m_pFtpConnection->OpenFile(file.GetFileName(),GENERIC_WRITE);[/u]
CString f;
f.Format("%s",file.GetFileName());
m_label.Format("Envoie %s",f);
SetDlgItemText(IDC_LABEL,m_label);
if(!pInternetFile){MessageBox(NULL,"Marche pas",MB_OK);}
m_dwFileLength = file.GetLength ();
char buffer[BUF_SIZE];
unsigned int nRead = BUF_SIZE;
unsigned int nTotalRead = 0;
while ( nRead == BUF_SIZE && (WaitForSingleObject(m_hEventKill, 0) == WAIT_TIMEOUT) &&(!(false)))
{
nRead = file.Read(buffer, BUF_SIZE);
pInternetFile->Write(buffer,nRead);
nTotalRead += nRead;
sTemp.Format ("%s (%d of %d KBytes transferred)", fname, nTotalRead / 1024, m_dwFileLength / 1024);
SetDlgItemText(IDC_L1,sTemp);
if (m_dwFileLength > 0)
{
int nPos = (nTotalRead * 100) / m_dwFileLength;
m_progress.SetPos (nPos);
}
else
{
m_progress.SetPos(0);
}
}
file.Close();
pInternetFile->Close();
delete pInternetFile;
m_pFtpConnection->Close();
delete m_pFtpConnection;
m_pInetSession.Close();
WaitForSingleObject(m_hEventKill,0); |
Partager