|
在WinForm中通过HTTP协议向服务器端上传文件(15) loFile.Read(lcFile,0,(int) loFile.Length); loFile.Close(); } catch(Exception e) { this.cErrorMsg = e.Message; this.bError = true; return false; } this.oPostData.Write( Encoding.GetEncoding(1252).GetBytes( "--" + this.cMultiPartBoundary + "\r\n" + "Content-Disposition: form-data; name=\"" + Key + "\" filename=\"" + new FileInfo(FileName).Name + "\"\r\n\r\n") ); this.oPostData.Write( lcFile ); this.oPostData.Write( Encoding.GetEncoding(1252).GetBytes("\r\n")) ; return true; } /// <summary> /// Return a the result from an HTTP Url into a StreamReader. /// Client code should call Close() on the returned object when done reading. /// </summary> /// <param name="Url">Url to retrieve.</param> /// <param name="WebRequest">An HttpWebRequest object that can be passed in with properties preset.</param> /// <returns></returns> protected StreamReader GetUrlStream(string Url,HttpWebRequest Request) { try { this.bError = false; this.cErrorMsg = "";
if (Request == null) { Request = (HttpWebRequest) System.net.WebRequest.Create(Url); }
|