string StrUrl = "http://img.bimg.126.net/photo/c7bckFJxdJxSwQLIy76HTQ==/1755840904721658663.jpg"; 
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(StrUrl);
            System.IO.Stream ns = request.GetResponse().GetResponseStream();
            ns.Seek(0, SeekOrigin.Begin);提示:此流不支持查询操作。有什么办法能使它支持查询操作

解决方案 »

  1.   

    看看对你有用没?不知道你想干嘛,流的查找,请参阅msdn的stream
            private string HttpRequestFun(string url, int port)
            {
                string html = "";
                try
                {
                    WebRequest req = WebRequest.Create(url);
                    req.Method = "POST";   //指定提交的Method,可以为POST和GET,一定要大写                   byte[] postData = System.Text.Encoding.GetEncoding("utf-8").GetBytes("?param1=aaa&param2=bbb");//Post的数据                   req.ContentLength = postData.Length;
                    Stream postStream = req.GetRequestStream();
                    postStream.Write(postData, 0, postData.Length);
                    postStream.Close();                WebResponse res = req.GetResponse();                System.Text.Encoding resEncoding = System.Text.Encoding.GetEncoding("utf-8");//接收的编码   
                    StreamReader reader = new StreamReader(res.GetResponseStream(), resEncoding);                html = reader.ReadToEnd();     //接收的Html                   reader.Close();
                    res.Close();
                }
                catch (Exception e2)
                {
                    html += e2.Message;
                }            return html;
            }
      

  2.   

    byte[] bytes = new byte[ns.Length];
    stream.Read(bytes, 0, bytes.Length);
    stream.Seek(0, SeekOrigin.Begin);
      

  3.   

    HttpWebRequest   myReq   =   (HttpWebRequest)HttpWebRequest.Create(strUrl);   
    string filepath= "";
    int   start   =   strUrl.LastIndexOf("/",strUrl.Length);   
    string filename   =   strUrl.Substring(start,strUrl.Length - start);   
    HttpWebResponse   HttpWResp=(HttpWebResponse)myReq.GetResponse();   
    StreamReader   sr=new StreamReader(HttpWResp.GetResponseStream(),System.Text.Encoding.Default);   
    StreamWriter   sw   =   new   StreamWriter(filepath+filename);   
    sw.Write(sr.ReadToEnd());   
    sw.Close();   
    sr.Close();