VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Internet File Transfer From Website

by webdataconsultants (1 Submission)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

This is a module for easily adding the ability to transfer a file from a webserver to a hard drive. Good for a "live update" type of functionality or for downloading banners to your program. By Erick Jones, https://www.webdataconsultants.com

Inputs
You must provide a URL of the source file and a filename for the downloaded file name
Assumes
First of all, this is a module. You'll have to add the module to your project. You also have to add a Microsoft Internet Transfer Control (and a Label1 Control if you are using the example below) to your form. EXAMPLE USAGE: Label1.Caption = "Getting File..." TransferFile = Xfer(Inet1, "http://www.webdata.addr.com/index.html", App.Path + "\index.html") Label1.Caption = InetStatus
Code Returns
InetStatus returns the status of the file transfer or an error if the transfer is unsuccessful.
API Declarations
Global TransferFile As Boolean
Global b() As Byte
Global InetStatus As String

Rate Internet File Transfer From Website

'####################################
'# Created 2002 Webdata Consultants #
'# You are free to use this module #
'# as long as you keep this header #
'# intact.       #
'# www.webdataconsultants.com  #
'####################################
'
'First of all, to use this module you have
'add a Microsoft Internet Transfer Control
'and a Label1 Control to your form.
'
'EXAMPLE USAGE:
 'Label1.Caption = "Getting File..."
 'TransferFile = Xfer(Inet1, "http://www.webdata.addr.com/index.html", App.Path + "\index.html")
 'Label1.Caption = InetStatus
Global TransferFile As Boolean
Global b() As Byte
Global InetStatus As String
Public Function Xfer(Inet1 As Inet, strURL As String, InputFile As String) As Boolean
 On Error GoTo ErrorHandle
 Inet1.AccessType = icUseDefault
 Inet1.RequestTimeout = 10 'Higher number increases request timeout
 b() = Inet1.OpenURL(strURL, icByteArray)
 Open InputFile For Binary Access _
 Write As #1
 Put #1, , b()
 Close #1
 InetStatus = "Done"
Exit Function
ErrorHandle:
 Select Case Err.Number
  Case 75
   InetStatus = "Destination file is read-only."
  Case 35761
   InetStatus = "Request timed out. Please check your internet connection or try again later."
  Case Else
   InetStatus = "Error: " & Err.Number
 End Select
End Function

Download this snippet    Add to My Saved Code

Internet File Transfer From Website Comments

No comments have been posted about Internet File Transfer From Website. Why not be the first to post a comment about Internet File Transfer From Website.

Post your comment

Subject:
Message:
0/1000 characters