VB2008 加载URL地址的图片问题
如果想获取 一个http中的图片,,应该怎么编写?谢谢高手!
--------------------编程问答--------------------
Public Class Form1
Sub DownFile(ByVal URL As String)
Dim bytes() As Byte
' 把文件的字节读到一个Byte数组中
bytes = WebClient1.DownloadData(URL)
' 得出文件名
Dim tempS
tempS = Split(URL, "/")
Dim fName As String
fName = tempS(UBound(tempS))
' 保存在C盘下
Dim FS As New System.IO.FileStream("C:\" & fName, IO.FileMode.CreateNew)
Dim Bw As New System.IO.BinaryWriter(FS, System.Text.Encoding.Unicode)
Bw.Write(bytes)
Bw.Close() '记住,操作完成后及时关闭Bw,否则出错.
PictureBox1.Image = Image.FromFile("C:\" & fName)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim text As String = "http://images.bokee.com/mm/index/2009-06-22/0X4R8Y5o1g7BeHZN.jpg"
DownFile(text)
MsgBox("到C盘找刚下载的文件!")
End Sub
Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
End Class
补充:VB , 网络编程