CLR: .Net / Mono / Boo / Otros CLR > VB .NET

 Descargar Archivo & Abrir Una Url

(1/1)

SJK:
Hola, como bien explica el título, lo que deseo es que haciendo click en un boton se descargue un archivo al ordenador desde el que se hizo click. También les agradecería que se abriera una nueva ventana con una url, sin tener que usar un linklabel.

Gracias por gastar su tiempo en hacerme caso, salu2

senzao18:
Para leer yo hago lo siguiente.....No recuerdo de donde lo saque pero si funciona.......

Creo que lo que hace es......Bajarlo y te muestra el status en un progres bar.....
imagino que se puede simplificar jeje....


--- Código: Text ---  Imports System.IOImports System.Net  Private Sub Download(ByVal sUrl As String, ByVal sFilePath As String)        'Initialize Download        _oWebClient = New WebClient        _oStream = _oWebClient.OpenRead(sUrl)        _oFile = New FileStream(sFilePath, FileMode.Create)        _oStream.BeginRead(_DataBuffer, 0, 8192, AddressOf AsynDownload, Nothing)    End Sub  Private Sub AsynDownload(ByVal ar As IAsyncResult)        Dim intCount As Integer        Try            intCount = _oStream.EndRead(ar)            If intCount < 1 Then                _oStream.Close()                _oFile.Close()                _oWebClient.Dispose()                'MsgBox("Done")                ProgressBar1.Value = 0                ContinueInstall()                Exit Sub            End If             _iTotalBytes += intCount            _oFile.Write(_DataBuffer, 0, intCount)            Dim params() As Object = {_iTotalBytes}            Me.Invoke(New BarInvoker(AddressOf Me.DisplayBar), params)            _oStream.BeginRead(_DataBuffer, 0, 8192, AddressOf AsynDownload, Nothing)         Catch e As Exception            MsgBox(e.Message)        End Try    End Sub     Private Sub DisplayBar(ByVal byteCount As Integer)        If ProgressBar1.Maximum > byteCount \ 1024 Then            ProgressBar1.Value = byteCount \ 1024        End If    End Sub   

Navegación

[0] Índice de Mensajes

Ir a la versión completa