C# winform 怎么下载文件? 用Httpreqeust的get方式 返回的是一个application/vnd.ms-excel 如果是用浏览器打开网页 他是自动弹出下载 请问 用winform的话 怎么下载? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不行的 他不是一个文件类型 他的请求地址是这样的http://www.segns.com/SMST/exportTestSendReceiveAction.do?str={"selected":[{"id":88}]}用HTTP ANALYZER 可以看到他的response content是一个application/vnd.ms-excel类型的文件 try { WebClient client = new WebClient(); client.DownloadFile("http://www.aaa.com", "bbb.jpg"); }catch (WebException webEx) { if(webEx.Status == WebExceptionStatus.ConnectFailure) { Console.WriteLine("请查看是否关闭防火墙.."); }} http://topic.csdn.net/u/20100820/17/6cbcb575-e002-4e04-a821-d4bb5573db56.html?42565 ftpwebrequest下载private void DownLoadFile(string address,string filename) {//address 文件下载路径,filename文件存放的本地路径 WebClient client=new WebClient(); client.DownloadFile(address,filename); Stream str=client.OpenRead(address); StreamReader reader=new StreamReader(str); byte[] mbyte=new byte[str.Length+1]; int allmybyte=(int)mbyte.Length; int startmbyte=0; while(allmybyte>0) { int m=str.Read(mbyte,startmbyte,allmybyte); if(m==0) { break; } startmbyte+=m; allmybyte-=m; } FileStream fstr=new FileStream(filename,FileMode.OpenOrCreate,FileAccess.Write); fstr.Write(mbyte,0,startmbyte); str.Close(); fstr.Close(); } 字符串截取求助。。 SqlDataReader怎么接收sp_helpdb返回的两个表的内容 提示下载FLASH插件 ACCESS 不同库里的表的数据对比有没有什么好办法? 初级问题~局部变量未赋值,我该怎么办..急用 c# 我想在一个软件里添加一个在线咨询的功能 c#如何在窗体中创建菜单 如何用c#编写此程序 求助 C#程序联网时启动非常慢,断网时启动正常 低级问题!!!(请进) 序列化对象的问题 添加引用Excel出现问题!
不行的 他不是一个文件类型
他的请求地址是这样的http://www.segns.com/SMST/exportTestSendReceiveAction.do?str={"selected":[{"id":88}]}用HTTP ANALYZER 可以看到他的response content是一个application/vnd.ms-excel类型的文件
WebClient client = new WebClient();
client.DownloadFile("http://www.aaa.com", "bbb.jpg");
}
catch (WebException webEx) {
if(webEx.Status == WebExceptionStatus.ConnectFailure) {
Console.WriteLine("请查看是否关闭防火墙..");
}
}
private void DownLoadFile(string address,string filename)
{//address 文件下载路径,filename文件存放的本地路径
WebClient client=new WebClient();
client.DownloadFile(address,filename);
Stream str=client.OpenRead(address);
StreamReader reader=new StreamReader(str);
byte[] mbyte=new byte[str.Length+1];
int allmybyte=(int)mbyte.Length;
int startmbyte=0;
while(allmybyte>0)
{
int m=str.Read(mbyte,startmbyte,allmybyte);
if(m==0)
{
break;
}
startmbyte+=m;
allmybyte-=m;
}
FileStream fstr=new FileStream(filename,FileMode.OpenOrCreate,FileAccess.Write);
fstr.Write(mbyte,0,startmbyte);
str.Close();
fstr.Close();
}