我要做个程序更新的程序!
但是网上的例子都无法下载超过64K的!
请问谁给编写个可以下载5M大文件,并有进度条的程序原代码!

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3524/3524450.xml?temp=.8611566
      

  2.   

    http://www.vckbase.com/code/downcode.asp?id=1968
    一个提供简单自动升级功能的代码。
    不过是vc编的
      

  3.   

    Private Sub Command1_Click()
        
        Dim b() As Byte
        Dim strURL As String
        
        strURL = "http://www.downXXX.com/XXX.rar"  '自己找个URL试试!
        
        b() = Inet1.OpenURL(strURL, icByteArray)
        right1 = Inet1.StillExecuting
        Do While right1
            right1 = Inet1.StillExecuting
            DoEvents
        Loop
        Open "c:\XXX.rar" For Binary Access _
        Write As #1
        Put #1, , b()
        Close #1
    End Sub
      

  4.   

    可以的.
    '首先做一个用户控件.
    '代码如下
    Event DownloadProgress(CurBytes As Long, MaxBytes As Long, SaveFile As String)
    Event DownloadError(SaveFile As String)
    Event DownloadComplete(MaxBytes As Long, SaveFile As String)Private Sub UserControl_AsyncReadComplete(AsyncProp As AsyncProperty)
        On Error Resume Next
        Dim f() As Byte, fn As Long
        If AsyncProp.BytesMax <> 0 Then
            fn = FreeFile
            f = AsyncProp.Value
            Open AsyncProp.PropertyName For Binary Access Write As #fn
            Put #fn, , f
            Close #fn
        Else
            RaiseEvent DownloadError(AsyncProp.PropertyName)
        End If
        RaiseEvent DownloadComplete(CLng(AsyncProp.BytesMax), AsyncProp.PropertyName)
    End Sub
    Private Sub UserControl_AsyncReadProgress(AsyncProp As AsyncProperty)
        On Error Resume Next
        If AsyncProp.BytesMax <> 0 Then
            RaiseEvent DownloadProgress(CLng(AsyncProp.BytesRead), CLng(AsyncProp.BytesMax), AsyncProp.PropertyName)
        End If
    End Sub
    Private Sub UserControl_Initialize()
        SizeIt
    End Sub
    Private Sub UserControl_Resize()
        SizeIt
    End Sub
    Public Sub BeginDownload(url As String, SaveFile As String)
        On Error GoTo ErrorBeginDownload
        UserControl.AsyncRead url, vbAsyncTypeByteArray, SaveFile, vbAsyncReadForceUpdate
        Exit Sub
    ErrorBeginDownload:
        Debug.Print Err & ":Error in call to BeginDownload()." _
        & vbCrLf & vbCrLf & "Error Description: " & Err.Description, vbCritical, "Warning"
        Exit Sub
    End Sub
    Public Sub SizeIt()
        On Error GoTo ErrorSizeIt
        With UserControl
            .Width = ScaleX(32, vbPixels, vbTwips)
            .Height = ScaleY(32, vbPixels, vbTwips)
        End With
        Exit Sub
    ErrorSizeIt:
        MsgBox Err & ":Error in call to SizeIt()." _
        & vbCrLf & vbCrLf & "Error Description: " & Err.Description, vbCritical, "Warning"
        Exit Sub
    End Sub
    '然后在窗体中把这个控件画到窗口中.再写如下代码
    '加一个commandbutton按钮,名为cmdDOWNLOAD
    '再加一个进度条控件ProgressBar,名为prgBARPrivate Sub cmdDOWNLOAD_Click()
        On Error Resume Next
        Me.Downloader1.BeginDownload "http://dl7.mydown.com/soft1/200411/HA-flashfxp302b1045final-LDR.zip", "f:\abc.zip"'这是下载的地址跟你想保存的路径.
        Me.prgBAR.Visible = True
    End Sub
    Private Sub Downloader1_DownloadComplete(MaxBytes As Long, SaveFile As String)
        Me.prgBAR.Visible = False
        Me.lblPROGRESS.Caption = "Complete."
    End SubPrivate Sub Downloader1_DownloadError(SaveFile As String)
    MsgBox "下载出现错误,请重新下载!"
    End SubPrivate Sub Downloader1_DownloadProgress(CurBytes As Long, MaxBytes As Long, SaveFile As String)
        On Error Resume Next
        With Me.prgBAR
            .Max = MaxBytes
            .Value = CurBytes
        End With
        Debug.Print SaveFile
        Me.lblPROGRESS.Caption = CurBytes & " of " & MaxBytes
    End Sub
    Private Sub Form_Load()
        Me.lblPROGRESS.Caption = ""
    End Sub
      

  5.   

    在普通的EXE程序编制中选择添加用户控件!
    然后把上面的添进去!把控件添到你的form中就可以了!
    控件要命名为Downloader1
    我已经测试可以使用!