Microsoft KB Archive/182316

From BetaArchive Wiki
Knowledge Base


INFO: FTP Append Functionality not Available from WinInet

Article ID: 182316

Article Last Modified on 5/17/2002



APPLIES TO

  • Microsoft Internet Explorer 3.02
  • Microsoft Internet Explorer 4.01 Service Pack 2
  • Microsoft Internet Explorer 5.0
  • Microsoft Windows Internet Services (WinInet)



This article was previously published under Q182316

SUMMARY

The Win32 Internet Extensions, or WinInet (WinInet.dll), do not directly implement functionality to enable FTP appends.

MORE INFORMATION

WinInet provides access to common Internet protocols, including Gopher, FTP, and HTTP. Using WinInet, you can write Internet client applications at a higher level of programming, without having to deal with WinSock, TCP/IP, or the details of specific Internet protocols.

FTP commonly exposes an "append" command to append one file to another. WinInet does not directly expose this functionality.

In Internet Explorer 3.0 and 4.0, the workaround for this problem is to download the file from the server, append to it on the client then upload the file back to the server.

Beginning with Internet Explorer 5, FTP commands can be sent directly to the FTP server using the FtpCommand as follows:

CHAR szTemp[256];
wsprintf (szTemp, "APPE %s", "DestFile.txt");

bRet = FtpCommand( hConnection,// WinInet Connection handle
TRUE,// Yes, I expect a response
FTP_TRANSFER_TYPE_ASCII,// I'm receiving ASCII
szTemp,// This is the FTP command I am passing
0,// No context needed
&hResponse);// The handle to read the response 
if (!bRet)
{
cout << "FtpCommand failed, error: " << GetLastError() << endl;
return;
}

wsprintf (szTemp, "This data will be appended to the file");

DWORD dwSize;
if (!InternetWriteFile (hResponse, (LPVOID)szTemp, lstrlen(szTemp)+1, &dwSize))
{
cout << "InternetWriteFile failed, error: " << GetLastError() << endl;
return;
}
                

For additional information on the use of the FtpCommand function, click the article number below to view the article in the Microsoft Knowledge Base:

238273 SAMPLE: Ftpcmd.exe WinInet FtpCommand() Function Sample


An alternative to either of these approaches would be to use Winsock to directly communicate with the FTP server.

REFERENCES

For additional information on other limitations of the WinInet FTP functions, click the article number below to view the article in the Microsoft Knowledge Base:

172712 INFO: Limitations of WinInet FTP Functions


For more information, please see the following topics on the Microsoft Developer Network (MSDN) Library:

  • Microsoft Internet Client SDK
  • Microsoft Platform SDK



Additional query words: kbdsi kbftp

Keywords: KB182316