BUG: FtpOpenFile Fails If Files Are Not Read Completely

ID: Q238796


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5


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 this to be a bug in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

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 << "  " <BR/>
              << 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";
  }

} 

Additional query words:

Keywords : kbIE400 kbIE401sp1 kbIE401sp2 kbIE500 kbDSupport
Version : WINDOWS:4.0,4.01,4.01 SP1,4.01 SP2,5
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: October 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.