用Httpreqeust的get方式 返回的是一个application/vnd.ms-excel  
如果是用浏览器打开网页 他是自动弹出下载
 请问 用winform的话 怎么下载?

解决方案 »

  1.   


    不行的 他不是一个文件类型  
    他的请求地址是这样的http://www.segns.com/SMST/exportTestSendReceiveAction.do?str={"selected":[{"id":88}]}用HTTP ANALYZER 可以看到他的response content是一个application/vnd.ms-excel类型的文件
      

  2.   

    try {
        WebClient client = new WebClient();         
        client.DownloadFile("http://www.aaa.com", "bbb.jpg");        
    }
    catch (WebException webEx) {
        if(webEx.Status == WebExceptionStatus.ConnectFailure) {
              Console.WriteLine("请查看是否关闭防火墙..");
        }
    }
      

  3.   

    http://topic.csdn.net/u/20100820/17/6cbcb575-e002-4e04-a821-d4bb5573db56.html?42565
      

  4.   

    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();
            }