|
在WinForm中通过HTTP协议向服务器端上传文件(23) if (oArgs.Cancel) goto CloseDown; } } } // while CloseDown: oHttpResponse.Close();
// *** Send Done notification if (this.OnReceiveData != null && !oArgs.Cancel) { // *** Update the event handler oArgs.Done = true; this.OnReceiveData(this,oArgs); } // return lcHtml; return loWriter.ToString(); } public delegate void OnReceiveDataHandler(object sender, OnReceiveDataEventArgs e); public class OnReceiveDataEventArgs { public long CurrentByteCount=0; public long TotalBytes = 0; public int NumberOfReads = 0; public char[] CurrentChunk; public bool Done = false; public bool Cancel = false; } }
在wwHttp这个类里面,不仅仅可以传送文件AddPostFile方法,还可以传送变量AddPostKey方法。
这样,如果我们要通过代理服务器传送文件,就可以编写如下的代码了: wwHttp ww = new wwHttp(); ww.ProxyAddress = "202.132.156.124"; ww.PostMode = 2; ww.AddPostKey("testKey","test"); ww.AddPostFile("myfile",@"D:\Temp\Java\JavaStart\JavaStart2.jar"); string shtml = ww.GetUrlEvents("http://localhost/UploadFileWeb/WebForm1.ASPx",409600);
|