方法1示例代码:
--------------
string strImageURL = "http://192.168.0.1:88/VDirA/images/1.jpg";
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.DownloadFile(strImageURL, @"D:\1.jpg");
方法2示例代码:
--------------
string strImageURL = "http://192.168.0.1:88/VDirA/images/1.jpg";
System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strImageURL);
webRequest.Method = "GET";
System.Net.HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse();
System.IO.Stream s = webResponse.GetResponseStream();
List<byte> list = new List<byte>();
while (true)
{
int data = s.ReadByte();
if (data == -1)
break;
else
{
byte b = (byte)data;
list.Add(b);
}
}
byte[] bb = list.ToArray();
System.IO.File.WriteAllBytes("C://1.jpg", bb);
s.Close();