POST以文件流的方式发送 和接收

以文件流的方式发送 和接收

      postData += ("&hashcode=" + GetMD5String(pwd));
            //byte[] data = encoding.GetBytes(postData);
            byte[] data = System.Text.Encoding.UTF8.GetBytes(postData);

            // Prepare web request...
            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("url");
            myRequest.Method = "POST";
            myRequest.ContentType = "application/x-www-form-urlencoded";
            myRequest.ContentLength = data.Length;
            Stream newStream = myRequest.GetRequestStream();
            // 发送数据
            newStream.Write(data, 0, data.Length);
            newStream.Close();
            // 接收
            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
            StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
            string content = reader.ReadToEnd();

posted on 2013-11-07 17:36  峰翼  阅读(3018)  评论(0编辑  收藏  举报

导航