Results 1 to 2 of 2

Thread: IE Post for HEADBANGER

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181

    IE Post for HEADBANGER

    Didn't know where you post went but i just can't find it. Here is the code as promised, sos about the delay - bank holiday and all that.

    Friend Sub GetText(ByVal URL As String)
    Try
    Dim download As cDownload = New cDownload(URL, "Text")
    download.downloadfile()
    Catch ex As Exception

    End Try
    End Sub

    That calls the following class
    Imports System.IO
    Imports System.Net

    Public Class cDownload
    Private ReadOnly sURL As String
    Private ReadOnly sFileName As String

    Public Sub New(ByVal url As String, ByVal Type As String)
    'Requires full qualified path
    Me.sURL = url
    Select Case Type
    Case "Image"
    Me.sFileName = Application.StartupPath & "\image.gif"
    Case "Text"
    Me.sFileName = Application.StartupPath & "\DownloadedWebPage.htm"
    End Select

    End Sub

    Public Sub downloadfile()
    Dim myClient As WebClient = New WebClient()
    Dim Done As Boolean = False
    While (Not Done)
    Try
    'delete exisiting file if it exists
    If (File.Exists(sFileName)) Then
    File.Delete(sFileName)
    End If
    myClient.DownloadFile(sURL, sFileName)
    Done = True
    Catch ex As Exception
    Done = True
    End Try
    End While

    End Sub

    End Class

    Enjoy!
    Wind and waves resolves all problems.

  2. #2
    Member
    Join Date
    Aug 2002
    Posts
    41
    thanks, helped a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width