|
-
Aug 27th, 2002, 12:03 PM
#1
Thread Starter
Addicted Member
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.
-
Aug 29th, 2002, 12:40 AM
#2
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|