OpenURL Method Example

The example uses the OpenURL method to retrieve the directory of an FTP server. To try the example, place an Internet Transfer control and a RichTextBox control on a form. Paste the code into the Declarations section. Press F5 to run the example, and double-click on the form.

Private Sub Form_DblClick()
   Inet1.AccessType = icUseDefault
   RichTextBox1.Text = Inet1.OpenURL _
   (InputBox("URL", , "ftp://ftp.microsoft.com"))
End Sub

This example presumes the data is a binary file. Using a byte array, the file is retrieved and written to the disk using the Open, Put, and Close statements. To try the example, place an Internet Transfer control on a form and paste the code into the Declarations section. Press F5 and double-click on the form.

Private Sub Form_DblClick()
   Inet1.AccessType = icUseDefault
   Dim b() As Byte
   Dim strURL As String

   ' Presuming this is still a valid URL.
   strURL = "ftp://ftp.microsoft.com/" & _
   "developr/drg/Win32/Autorun.zip"

   ' Retrieve the file as a byte array.
   b() = Inet1.OpenURL(strURL, icByteArray)
   
   Open "C:\Temp\Autorun.zip" For Binary Access _
   Write As #1
   Put #1, , b()
   Close #1
   MsgBox "Done"
End Sub