Articulo escrito

  • on 30.09.2008
  • a las 10:09 PM
  • por rhypee

Ejemplo para descargar archivos de internet con Visual Basic 2005 0

Sep30

Hoy os voy a poner un ejemplo para poder descargar archivos con visual basic 2005.

Los controles que vamos a necesitar son los siguientes:

- Un control Button
- Un control textbox llamado “txt_Url”
– Un control textbox llamado “txt_path_destino”

Una vez dicho esto, vamos con el codigo en cuestion:

1. Function Descargar_Archivo(ByVal Url As String, _
2. ByVal Path_Destino As String) As Boolean
3. If Url = vbNullString Or Path_Destino = vbNullString Then
4. MsgBox(”No se indicó la url o el archivo de destino”, _
5. MsgBoxStyle.Critical, “Error”)
6. Else
7. If Len(Dir(Path_Destino)) <> 0 Then
8. MsgBox(”el archivo destino ya existe. Por favor,escoja otro destino diferente”, _
9. MsgBoxStyle.Exclamation, “Error”)
10. Else
11. On Error Resume Next
12. My.Computer.Network.DownloadFile(Url, Path_Destino)
13. If Err.Number = 0 Then
14. Descargar_Archivo = True
15. Else
16. MsgBox(Err.Description)
17. End If
18. Err.Clear()
19. End If
20. End If
21. End Function
22.
23. Private Sub Form1_Load(ByVal sender As System.Object, _
24. ByVal e As System.EventArgs) _
25. Handles MyBase.Load
26. Button1.Text = “Download” ‘lo podemos llamar al boton como queramos.
27. End Sub
28.
29. Private Sub Button1_Click(ByVal sender As System.Object, _
30. ByVal e As System.EventArgs) Handles Button1.Click
31. Dim ret As Boolean
32. ret = Descargar_Archivo(txt_url.Text, txt_path_destino.Text)
33.
34. If ret Then
35. MsgBox(”El archivo se ha descargado correctamente”, MsgBoxStyle.Information)
36. End If
37.
38. End Sub

Si te gusto, comparteme These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • BarraPunto
  • Facebook
  • Google Bookmarks
  • Meneame
  • Technorati
  • TwitThis
  • Wikio ES

subscribe to comments RSS

Este post no no tiene aun comentarios

Escribe un comentario, es gratuito

* these are required fields

rhypee 2.0 is powered by WordPress and FREEmium Theme.
developed by Dariusz Siedlecki and brought to you by FreebiesDock.com