Get a Page or File Code Example

The following example demonstrates a Get using the Web control. The page or file is saved to disk once it is retrieved. Progress is displayed in a log.

 

Private Sub buttonGet_Click()
    GetPage("www.dart.com/myImage.jpg", App.Path & "\myImage.jpg")
End Sub

Private Sub GetPage(ByVal url As StringByVal filename As String)
    'Reset the Request Message.
    Web1.Request.Content = ""

    'Get the page or file.
    Web1.Request.url = url
    Web1.Get

    'Save the file to disk.
    Web1.response.Body.filename = filename
End Sub

Private Sub Web1_Progress(ByVal Method As DartWebASPCtl.WebMethodConstants, _
    ByVal Status As DartWebASPCtl.WebStatusConstants, ByVal Count As Long, _
    ByVal Size As Long)
    'Show progress during the Get.
    If Method = webGet And Status = webReceiving Then
        textLog.Text = textLog.Text + CStr(Count) + " of " + CStr(Size)
        textLog.Text = textLog.Text + + " bytes transferred." + vbCrLf
    End If
End Sub