遇到个很烦的问题...高手来点源码...或者方法...
http://bbs.game.mop.com/attachment.php?aid=599418
像这样的网址....WebClient不能解析啊... 

解决方案 »

  1.   

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://bbs.game.mop.com/attachment.php?aid=599418");
                request.AllowAutoRedirect = false;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                
                Stream dataStream = response.GetResponseStream();
                
                
                MessageBox.Show(response.Headers["Content-Disposition"]);
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
      

  2.   

           System.Net.WebClient _WebClient = new System.Net.WebClient();
                _WebClient.DownloadFile("http://bbs.game.mop.com/attachment.php?aid=599418",@"c:\1.rar");这样没问题啊
      

  3.   

     那怎么讲文件保存到本地...我MSDN里找不到有这个方法吗...
      

  4.   

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://bbs.game.mop.com/attachment.php?aid=599418");
                request.AllowAutoRedirect = false;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                            Stream dataStream = response.GetResponseStream();                        string[] strFieName= response.Headers["Content-Disposition"].TrimEnd().Split(new char[]{'\"'},StringSplitOptions.RemoveEmptyEntries);            
                
                byte[] filecontent = new byte[response.ContentLength];
                int count=dataStream.Read(filecontent, 0, filecontent.Length);
                while (count > 0)
                {
                    count = dataStream.Read(filecontent, count, filecontent.Length - count);
                }
                System.IO.File.WriteAllBytes(@"c:\" + strFieName[strFieName.Length-1], filecontent);             
                dataStream.Close();
                response.Close();
      

  5.   

    int offeset = 0;
                int count = dataStream.Read(filecontent, offeset, filecontent.Length);
                while (count > 0)
                {
                    offeset += count;
                    count = dataStream.Read(filecontent, offeset, filecontent.Length - offeset);
                }