C
ich nerver einige wahrscheinlich damit, aber ich bitte doch nochmals um Hilfestellung.
der Beitrag ist schon ganz gut
http://www.c-plusplus.net/forum/viewtopic-var-t-is-39100.html
Nur leider klappt der bei mir nicht. Ich habe Probleme mit SeektoEnd.
Sobald diese Methode ausgeführt wurde, wird sofort mein Programm beendet. Ohne irgendwelche Fehler. Ich will doch einfach nur wissen wie groß meine Datei auf dem Server ist
anbei mein Code
//**********GETFILE*****************************************
//**********************************************************
BOOL getfile()
{
//**********Definitionen*************************************
CString arg2 = __argv[2];
CString nFileSizeServer;
CString nFileSizeLocal;
CString FileName = "Downloading File: ";
CFile FileLocal;
CInternetFile* pNetFile;
int nFileSize = 0;
int nBytesToWrite = 0;
char cReadBuffer [512];
//***********************************************************
mo_textfield->SetWindowText(FileName + __argv[1]);
mo_statusbar->SetRange(0,309);
mo_statusbar->SetPos(0);
// Download starten und in Datei speichern
try
{
pNetFile = pFTPConnection->OpenFile(__argv[1],GENERIC_READ,FTP_TRANSFER_TYPE_BINARY,1);
//******DATEIGRÖßE ERMITTELN*********************************
nFileSizeServer.Format ("%i", pNetFile->GetLength());
// int max = atoi(nFileSizeServer);
AfxMessageBox(nFileSizeServer);
//***********************************************************
//******NEUE DATEI ERSTELLEN*********************************
FileLocal.Open(arg2+__argv[1], CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
while (nBytesToWrite = pNetFile->Read(cReadBuffer, 512))
{
FileLocal.Write(cReadBuffer, nBytesToWrite);
nFileSizeLocal.Format("%i", (FileLocal.GetLength()/1024));
int akt_kb = atoi(nFileSizeLocal);
mo_statusbar->SetPos(akt_kb);
}
pInternetSession->Close();
}
catch(CInternetException *IE)
{
return FALSE;
}
return TRUE;
}