Prev: IMPLEMENT_SERIAL_T and the like
Next: CStatic & Tooltip
From: F. Petri on 29 Mar 2005 07:38 Hello, I have an vxWorks FTP server running. I want to transfer a file to that server, but before transfering it I want to check if the file already exists, so the user can decide whether he wants to overwrite the file. I use CFtpFileFind to check if the file on the server alredy exists. Then I use CInternetFile to open the file, and write it on the server. This sometimes works, but sometimes CInternetFile::Open throws an CInternetException with m_dwError = 12003 ("The server returned extended information") and CInternetFile::GetErrorMessage returns "200 Type set to I, binary mode 200 Port set okay 426 Data connection error"). The MSDN states that 12003 does not necessarily mean an error, but the file is not created properly. The code below is to demonstrate the problem (in a reproducable way). The loop is necessary because the first 8 (or so) times everything runs fine, but then the exception is thrown. When the exception occurs, it does not help to shut down CInternetSession and CFtpConnection and set them up again and try to transfer the file again! The problem does not occur if - I use an Windows FTP server - I do not use CFtpFileFind Any help, however little, would be greatly appreciated. void CMyDialog::OnButtonFTPTransfer() { CInternetSession *pINetSession; CFtpConnection *pFtpConnection; pINetSession = new CInternetSession(NULL, 1, PRE_CONFIG_INTERNET_ACCESS); pFtpConnection = pINetSession->GetFtpConnection("10.168.2.200"); // a vxWorks FTP server char buffer[1000] = "This data will be written to the file"; int n; try { for (n = 0; n < 20; n++) { CFtpFileFind aFind(pFtpConnection); CInternetFile *pIFile; // if the following two lines are removed, the program runs aFind.FindFile(); aFind.Close(); pIFile = pFtpConnection->OpenFile("file.txt", GENERIC_WRITE); pIFile->Write(buffer, 37); pIFile->Close(); } } catch (CInternetException *pEx) { DWORD d = pEx->m_dwError; pEx->GetErrorMessage(buffer,999); AfxMessageBox("Exception caught"); return; } AfxMessageBox("success"); pFtpConnection->Close(); pINetSession->Close(); delete pFtpConnection; delete pINetSession; }
|
Pages: 1 Prev: IMPLEMENT_SERIAL_T and the like Next: CStatic & Tooltip |