Using FTP WinInet APIs in Visual Basic with SimpleFtp

ID: Q195653


The information in this article applies to:
  • Internet Client SDK, versions 4.0, 4.01
  • Microsoft ActiveX SDK, version 1.0
  • Microsoft Visual Basic Professional and Enterprise Editions for Windows, versions 5.0, 6.0


SUMMARY

This sample file demonstrates how to use WinInet FTP APIs in a Visual Basic (VB) application.


MORE INFORMATION

The sample demonstrates the following concepts:

  • How to enumerate a directory on the FTP server and return file information such as creation date and size.


  • How to upload large files to the FTP server without blocking the entire application and with reporting transfer progress. There are two ways of uploading a file:
    • By using the FtpPutFile() API. However, this API blocks until the entire file has been uploaded. Upon clicking the Put button, the sample will use this method.


    • By using FtpOpenFile and InternetWriteFile. Once the file is open it can be uploaded in chunks. This enables the application to report upload status and avoid blocking. It does this by calling DoEvents() between calling InternetWriteFile. Upon clicking the Put Large File button, the sample will use this method.




  • How to get text information for WinInet errors and how to retrieve extended error information. For simplicity, the sample does not implement downloading of the large files. This functionality is similar to method b) above; however, you should use the InternetReadFile API instead of InternetWriteFile.


Notes

  • This sample uses pre-configured access to the Internet. WinInet FTP APIs do not work if Internet access is accomplished via CERN type proxy.


  • This sample was created with Visual Basic 6.0. There may be an error if the project is opened in Visual Basic5.0.


  • WinInet documentation can be found at the following Web site:
    http://www.msdn.microsoft.com/workshop/


Click "Networking, Protocols & Data Formats" in the Table of Contents, then click "Win32 Internet Functions."

The following file is available for download from the Microsoft Download Center. Click the file name below to download the file:
VBSMPFTP.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.
Vbsmpftp.exe contains the following files:


   FileName               Size
   ---------------------------------------------------------

   ErrorForm.frm           1,216
   ErrorForm.frx           6
   readme.txt              1,869
   SimpleFtp.bas           5,364
   SimpleFtp.exe           40,960
   SimpleFtp.frm           13,491
   SimpleFtp.vbp           646
   SimpleFtp.vbw           118 


REFERENCES

For additional information, please see the following articles in the Microsoft Knowledge Base:

Q166961 HOWTO: FTP with CERN-Based Proxy Using WinInet API
Q193625 WinInet Error Codes (12001 through 12156)
Q216214 SAMPLE: FTP with CERN-Based Password Protected Proxy

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Leon Braginski, Microsoft Corporation

Additional query words:

Keywords : kbfile kbsample kbSDKInet401 kbDSupport
Version : WINDOWS:1.0,4.0,4.01,5.0,6.0
Platform : WINDOWS
Issue type : kbinfo


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