/// <summary> /// 上传文件。formData参数附加到url /// </summary> public static string Upload(string url, HttpParam formData, string filePath) { var urlt = String.Format("{0}?{1}", url, formData == null ? "" : formData.Format()); var data = new WebClient().UploadFile(urlt, "POST", filePath); return(Encoding.UTF8.GetString(data)); }
/// <summary> /// 以post方式提交,将响应编码为字串。 /// </summary> /// <param name="url"></param> /// <param name="param"></param> /// <param name="getParam"></param> /// <param name="timeOut">单位:秒</param> /// <param name="encoding"></param> /// <param name="cc"></param> /// <param name="refer"></param> /// <returns></returns> public static string Post(string url, HttpParam param = null, HttpParam getParam = null, int timeOut = TimeOut, Encoding encoding = null, CookieContainer cc = null, string refer = null) { var urlt = string.Format("{0}{1}", url, getParam == null ? "" : string.Format("?{0}", getParam.Format())); return(Post(urlt, FormatData(param), null, timeOut, encoding, cc, refer)); }