自己改吧! 呵呵 保证可以运行 不过是用的是 HTTP :)Private Sub Command1_Click() Dim strURL As String Dim bData() As Byte '数据变量 Dim intFile As Integer '可用文件变量 Dim i As Integer Dim ttt As String Timer1.Interval = 300 strURL = Text1 & "/refresh.txt" intFile = FreeFile() '将 intFile 设置为未使用的文件 ' OpenURL 方法的结果首先传入 Byte 数组, '然后将 Byte 数组保存到磁盘。 On Error Resume Next Kill App.Path & "\update\refresh.txt" On Error GoTo 0 bData() = Inet1.OpenURL(strURL, icByteArray) Open App.Path & "\update\refresh.txt" For Binary Access Write As #intFile Put #intFile, , bData() Close #intFile
' On Error Resume Next Open App.Path & "\update\refresh.txt" For Input As #1 ' 下载更新文件表 Do While Not EOF(1) Line Input #1, ttt If InStr(ttt, "|") Then '如果有的自动先下载再改名 strURL = Text1 & Trim(Left(ttt, InStr(ttt, "|") - 1)) intFile = FreeFile() '将 intFile 设置为未使用的文件 ' OpenURL 方法的结果首先传入 Byte 数组, '然后将 Byte 数组保存到磁盘。 On Error Resume Next Kill App.Path & Trim(Right(ttt, Len(ttt) - InStr(ttt, "|") - 2)) On Error GoTo 0 bData() = Inet1.OpenURL(strURL, icByteArray) Open App.Path & Trim(Right(ttt, Len(ttt) - InStr(ttt, "|") - 2)) For Binary Access Write As #intFile Put #intFile, , bData() Close #intFile 'FileCopy App.Path & "\update\" & Trim(Right(ttt, Len(ttt) - InStr(ttt, "|") + 1)), App.Path & "\" & Trim(Right(ttt, Len(ttt) - InStr(ttt, "|") + 1))
End If Loop Close #1 MsgBox "系统升级完毕!" Timer1.Interval = 0 End Sub
FTP文件其实用Internet Transfer 能实现,我已经在一个局域网中实现,但先建立拨号网络链接,我不知如何实现
Dim strURL As String
Dim bData() As Byte '数据变量
Dim intFile As Integer '可用文件变量
Dim i As Integer
Dim ttt As String
Timer1.Interval = 300 strURL = Text1 & "/refresh.txt"
intFile = FreeFile() '将 intFile 设置为未使用的文件
' OpenURL 方法的结果首先传入 Byte 数组,
'然后将 Byte 数组保存到磁盘。
On Error Resume Next
Kill App.Path & "\update\refresh.txt"
On Error GoTo 0
bData() = Inet1.OpenURL(strURL, icByteArray)
Open App.Path & "\update\refresh.txt" For Binary Access Write As #intFile
Put #intFile, , bData()
Close #intFile
' On Error Resume Next
Open App.Path & "\update\refresh.txt" For Input As #1 ' 下载更新文件表
Do While Not EOF(1)
Line Input #1, ttt
If InStr(ttt, "|") Then
'如果有的自动先下载再改名
strURL = Text1 & Trim(Left(ttt, InStr(ttt, "|") - 1))
intFile = FreeFile() '将 intFile 设置为未使用的文件
' OpenURL 方法的结果首先传入 Byte 数组,
'然后将 Byte 数组保存到磁盘。
On Error Resume Next
Kill App.Path & Trim(Right(ttt, Len(ttt) - InStr(ttt, "|") - 2))
On Error GoTo 0
bData() = Inet1.OpenURL(strURL, icByteArray)
Open App.Path & Trim(Right(ttt, Len(ttt) - InStr(ttt, "|") - 2)) For Binary Access Write As #intFile
Put #intFile, , bData()
Close #intFile
'FileCopy App.Path & "\update\" & Trim(Right(ttt, Len(ttt) - InStr(ttt, "|") + 1)), App.Path & "\" & Trim(Right(ttt, Len(ttt) - InStr(ttt, "|") + 1))
End If
Loop
Close #1
MsgBox "系统升级完毕!"
Timer1.Interval = 0
End Sub