2010年5月6日星期四

使用WebClient提交中文数据

 

            try
            {
                String url = "http://school.jxllt.com/family/famsmssend_action_new.asp";
                String data = "sel_recelist=" + teacher + "&txta_memo=" + msg;
                byte[] postData = Encoding.GetEncoding("GB2312").GetBytes(data);
                wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                byte[] res = wc.UploadData(url, "POST", postData);
            }
            catch (Exception exp)
            {
                MessageBox.Show(String.Format("程序运行期间发生错误,错误信息:{0}", exp.Message));
            }

没有评论:

发表评论