通过流获取Internet上的文件

HttpWebRequest httprequest = null;
        HttpWebResponse httpresponse = null;
        Stream sr = null;
        //try
        //{
            httprequest = (HttpWebRequest)WebRequest.Create("http://donor.km169.net/music/200410/5189.wma");
            httpresponse = (HttpWebResponse)httprequest.GetResponse();
                        httpresponse = (HttpWebResponse)httprequest.GetResponse();
            Stream stream = httpresponse.GetResponseStream();
            byte[] _byte = new byte[1024];
            int length,_length;
            FileStream fs = new FileStream(Server.MapPath("~/images/ty.wma"), FileMode.Create);
           _length=stream.Read(_byte, 0, 1024);
           while (_length > 0)
           {
               fs.Write(_byte, 0, _length);
               _length = stream.Read(_byte, 0, 1024);
           }
           fs.Flush();
           fs.Close();
           stream.Close();
           Response.Write("<script>alert(1);</script>");

posted on 2009-09-16 11:32  画一个圆圈  阅读(150)  评论(0编辑  收藏  举报

导航