很久没发代码了,今天来发些C#代码[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 yyf9989 的 blog


	// 南京千里独行 2005-3-17	
		
	/// <summary>
	/// 进度信息处理委托
	/// </summary>
	/// <param name="completedstep" type="int">已经完成的步骤数</param>
	/// <param name="totalstep" type="int">总的步骤数</param>
	public delegate void progresshandler( int completedstep , int totalstep );
	
	/// <summary>
	/// 通用函数集合
	/// </summary>
	public class yyfcommon
	{
		/// <summary>
		/// 向指定url使用post方法发送数据的例程,本函数不进行错误处理
		/// </summary>
		/// <param name="strurl">url字符串</param>
		/// <param name="bytsend">要发送的二进制数据</param>
		/// <param name="sendprogress">发送数据时的进度处理</param>
		/// <param name="acceptprogress">接受数据时的进度处理</param>
		/// <returns>接受到的二进制数据</returns>
		public static byte[] httppostdata(
			string strurl ,
			byte[] bytsend ,
			progresshandler sendprogress ,
			progresshandler acceptprogress )
		{
			// 发送数据
			system.net.httpwebrequest myreq =(system.net.httpwebrequest) system.net.webrequest.create( strurl );
			myreq.method = "post" ;
			system.io.stream mystream = myreq.getrequeststream();
			int icount = 0 ;
			if( sendprogress != null)	
				sendprogress( 0 , bytsend.length );
			while( icount < bytsend.length )
			{
				if( icount + 1024 > bytsend.length)
				{
					mystream.write(bytsend, icount , bytsend.length - icount );
					icount = bytsend.length ;
				}
				else
				{
					mystream.write(bytsend , icount , 1024);
					icount += 1024;
				}
				if( sendprogress != null)	
					sendpro

本文关键:很久没发代码了,今天来发些C#代码
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top