Avenger
July 21st, 1999, 03:12 PM
Downloading a file is no problem, but uploading a file is another story. The code is almost the same, instead of reading you write, but it doesn't work. If I trace into it, it looks like it's going to work, but when I close the file, the trace stops there and freezes. But if I run the program normaly, is frezzes the first time it goes into the while loop. This is what I have :
CInternetFile *iFile; //remote file
CFile lFile; //local file
char buf[512];
UINT end;
CDownloadDialog *dlg = (CDownloadDialog*) pParam; //I'm in a thread
iFile = dlg->ftp->OpenFile(remoteFile, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 1);
if(iFile) {
if(lFile.Open(localFile, CFile::modeRead)) {
memset(buf, 32, 512);
end = lFile.Read(buf, 512);
while( end == 512 ) {
//iFile->WriteString(&buf); //doesnt' work either
iFile->Write(&buf, end);
iFile->Flush();
end = lFile.Read(buf, 512);
}
}
}
lFile.Close();
iFile->Close();
delete iFile;
CInternetFile *iFile; //remote file
CFile lFile; //local file
char buf[512];
UINT end;
CDownloadDialog *dlg = (CDownloadDialog*) pParam; //I'm in a thread
iFile = dlg->ftp->OpenFile(remoteFile, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 1);
if(iFile) {
if(lFile.Open(localFile, CFile::modeRead)) {
memset(buf, 32, 512);
end = lFile.Read(buf, 512);
while( end == 512 ) {
//iFile->WriteString(&buf); //doesnt' work either
iFile->Write(&buf, end);
iFile->Flush();
end = lFile.Read(buf, 512);
}
}
}
lFile.Close();
iFile->Close();
delete iFile;