C# 下载资源

//创建一个初始化请求对象

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("http://wwww.baidu.com/m.mp3"));

                //设置下载相关参数
RequestState requestState = new RequestState();
requestState.BUFFER_SIZE = 1024;
requestState.BufferRead = new byte[requestState.BUFFER_SIZE];
requestState.Request = request;
requestState.SavePath = System.Web.HttpRuntime.AppDomainAppPath + FilePath;
requestState.FileStream = new FileStream(requestState.SavePath, FileMode.OpenOrCreate);
request.Headers.Add("media_id", media_id);
request.Headers.Add("msgtype", MsgType);
//开始异步请求资源
request.BeginGetResponse(new AsyncCallback(ResponseCallback), requestState);
上一篇:浅析SQL Server数据库中的伪列以及伪列的含义


下一篇:Linux bash - 常用操作命令