|
在WinForm中通过HTTP协议向服务器端上传文件(14) "Content-Disposition: form-data; name=\"" +Key+"\"\r\n\r\n") ); this.oPostData.Write( Value ); this.oPostData.Write( Encoding.GetEncoding(1252).GetBytes("\r\n") ); break; default: this.oPostData.Write( Value ); break; } } public void AddPostKey(string Key, string Value) { this.AddPostKey(Key,Encoding.GetEncoding(1252).GetBytes(Value)); } /// <summary> /// Adds a fully self contained POST buffer to the request. /// Works for XML or previously encoded content. /// </summary> /// <param name="PostBuffer"></param> public void AddPostKey(string FullPostBuffer) { this.oPostData.Write( Encoding.GetEncoding(1252).GetBytes(FullPostBuffer) ); } public bool AddPostFile(string Key,string FileName) { byte[] lcFile; if (this.nPostMode != 2) { this.cErrorMsg = "File upload allowed only with Multi-part forms"; this.bError = true; return false; } try { FileStream loFile = new FileStream(FileName,System.IO.FileMode.Open,System.IO.FileAccess.Read); lcFile = new byte[loFile.Length];
|