Microsoft KB Archive/238796

= BUG: FtpOpenFile Fails If Files Are Not Read Completely =

Article ID: 238796

Article Last Modified on 7/20/2001

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0

-



This article was previously published under Q238796



SYMPTOMS
After you open (FtpOpenFile) and close (InternetCloseHandle) several files under a directory, the next call to FtpOpenFile fails with error 12003 (ERROR_INTERNET_EXTENDED_ERROR), if you do not read (InternetReadFile) the previously opened files completely. The problem will not occur if the files are read completely, or if a new FTP connection is opened each for each FtpOpenFile call.



RESOLUTION
Call InternetReadFile and read all of the data off the handle.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
Add the following function OpenAndClose to the SDK FTPJR sample. Call it from FtpEnumDirectory. After opening and closing several files in a directory, the next call to FtpOpenFile fails with error 12003. If you uncomment the following while ( InternetReadFile ... ) statement, the error will not occur.

Entering "ls" and the FTP Jr command prompt will execute the FtpEnumDirectory function. void OpenAndClose(HINTERNET hFind, char *FileName) { HINTERNET handle; if (!(handle = FtpOpenFile(hConnect, FileName, GENERIC_READ,      FTP_TRANSFER_TYPE_BINARY | INTERNET_FLAG_TRANSFER_BINARY,0))) {     cout << "Failed to open file :" << FileName << "  "  << handle << endl; ErrorOut(GetLastError, "FtpOpenFile"); InternetCloseHandle(handle); } else {     char buff[1000]; unsigned long read; //while (InternetReadFile(handle, buff, 1000, &read) && read); if (!InternetCloseHandle(handle)) cout << "Failed to close handle"; }

}

Keywords: kbbug kbpending KB238796

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.