日斋
日新月异
 private string SendUrl(string url)
        {
            string StrReturn = "";
            WebResponse result = null;
            try
            {
                WebRequest req = WebRequest.Create(url);
                result = req.GetResponse();
                Stream ReceiveStream = result.GetResponseStream();
                Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
                StreamReader sr = new StreamReader(ReceiveStream, encode);
                Char[] read = new Char[256];
                int count = sr.Read(read, 0, 256);
                while (count > 0)
                {
                    String str = new String(read, 0, count);
                    StrReturn += str;
                    count = sr.Read(read, 0, 256);
                }
            }
            catch (Exception e)
            {
                StrReturn += e.ToString();
                StrReturn += "找不到请求 URI,或者它的格式不正确";
            }
            finally
            {
                if (result != null)
                {
                    result.Close();
                }
            }
            return StrReturn.Trim();
        }
posted on 2010-03-02 17:20  李承隆  阅读(549)  评论(0编辑  收藏  举报