|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
Using The Internet Transfer Control For FTP And HTTP OperationsYou use the Microsoft Internet transfer control to handle FTP and HTTP operations in Visual Basic. Using the HTTP protocol, you can connect to World Wide Web servers to retrieve HTML documents. With the FTP protocol, you can log on to FTP servers to download and upload files. The UserName and Password properties allow you to log on to private servers that require authentication. Otherwise, you can connect to public FTP servers and download files. The common FTP commands, such as CD and GET, are supported through the Execute method. You can keep track of the Internet transfer controls operations with the StillExecuting property. If this property is True, the control is working on a transfer and will not respond to other actions. The Internet transfer control performs asynchronous Internet transfers, so besides the StillExecuting property, Microsoft has given the control a StateChanged event. In this events handler procedure, you are kept up-to-date on whats going on with the Internet transfer control: Private Sub object_StateChanged(ByVal State As Integer) End Sub The State argument can take these values:
Note that when a request is finished, the State argument in the StateChanged event will be set to icResponseCompleted, and its safe to execute another command with the Internet transfer control. To add an Internet transfer control to a program, follow these steps:
When you start an FTP or HTTP operation with the Internet transfer control, the control will connect to the Internet (using the users system defaults) if the computer is not already connected.
Now that weve added an Internet transfer control to a program, well put that control to work in the next few topics. Handling FTP Operations In Visual BasicThere are two ways of handling FTP operations with the Microsoft Internet transfer control: using the OpenUrl method and using the Execute method. The OpenUrl method lets you download files and uses the FTP protocol if the URL you specify begins with ftp:// (for example, ftp://ftp.microsoft.com/file.txt); heres how you use OpenUrl: InetControl.OpenUrl url [, datatype] The datatype argument can either be icString (the default) for text data or icByteArray for binary data. If you use icString, OpenUrl returns a string; if you use icByteArray, OpenUrl returns a byte array. The Execute method can execute FTP commands. Heres how you use Execute: InetControl.Execute url, operation, data, requestHeaders Heres what the arguments to Execute mean:
The FTP commands that you can use with the Internet transfer control and what they do appear in Table 21.3.
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |