1,WebRequest和WebResponse
WebRequest request = WebRequest.Create("http-://images.cnblogs.-com/logo_small.gif");
WebResponse response = request.GetResponse();
Stream reader = response.GetResponseStream();
FileStream writer = new FileStream("x:\\pic.jpg", FileMode.OpenOrCreate, FileAccess.Write);
byte[] buff = new byte[512];
int c = 0; //实际读取的字节数
while ((c=reader.Read(buff, 0, buff.Length)) > 0)
{
writer.Write(buff, 0, c);
}
writer.Close();
writer.Dispose();
reader.Close();
reader.Dispose();
response.Close();
希望给改成VB.NET
WebRequest request = WebRequest.Create("http:-//images.cnblogs.-com/logo_small.gif")
Dim response As WebResponse = request.GetResponse()
Dim reader As Stream = response.GetResponseStream()
Dim writer As New FileStream("x:\pic.jpg", FileMode.OpenOrCreate, FileAccess.Write)
Dim buff(511) As Byte
Dim c As Integer = 0 '实际读取的字节数
c=reader.Read(buff, 0, buff.Length)
Do While c > 0
writer.Write(buff, 0, c)
c=reader.Read(buff, 0, buff.Length)
Loop
writer.Close()
writer.Dispose()
reader.Close()
reader.Dispose()
response.Close()