C# WinForm 通过URL取得服务器上的某图片文件到本地
2008-12-03 08:51
573 查看
方法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();
--------------
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();
相关文章推荐
- C# WinForm 通过URL取得服务器上的某图片文件到本地
- C# WinForm 通过URL取得服务器上的某图片文件到本地
- 客户端通过C# 代码直接从服务器下载文件到本地
- 通过URl将服务器的图片下载到本地并压缩
- asp.net(c#)从url网络地址下载图片或文件到本地硬盘
- C# WinForm 上传图片,文件到服务器的方法Uploader.ashx
- c#通过URL地址从服务器上下载文件
- 下载(二)客户端通过C# 代码直接从服务器下载文件到本地
- Utils 图片通过Url获取流用Sftp向文件服务器存储
- 下载(二)客户端通过C# 代码直接从服务器下载文件到本地
- C# Winform 上传本地文件到服务器路径
- C# WinForm 上传图片,文件到服务器的方法Uploader.ashx
- C# Winform 上传本地文件到服务器路径
- C# WinForm 上传图片,文件到服务器的方法Uploader.ashx
- Android 视频开发中如何通过url或者本地视频文件路径获得视频的第一帧图片
- 通过URLHttpConnection方式来取得图片,并且显示在ImageView上
- c# winform 删除硬盘上的文件或者删除图片
- bat脚本使本地通过ftp和服务器传输文件
- C# 通过用application.startuppath+tmp创建图片存储临时虚拟文件
- 通过python模块实现服务器和本地机器之间快速拷贝文件