当前位置: 首页 > news >正文

湘潭网站建设 排名磐石网络提供邯郸移动网站建设

湘潭网站建设 排名磐石网络,提供邯郸移动网站建设,网站浏览量提升,广州自助企业建站模板如果下载多个文件的时候#xff0c;有时候莫名其妙的出现500服务器错误#xff0c;很有可能是没有设置KeepAlive 属性导致的。 出现应用程序未处理的异常#xff1a;2015/1/6 11:40:56 异常类型#xff1a;WebException 异常消息#xff1a;远程服务器返回错误: (500) 语法… 如果下载多个文件的时候有时候莫名其妙的出现500服务器错误很有可能是没有设置KeepAlive 属性导致的。 出现应用程序未处理的异常2015/1/6 11:40:56 异常类型WebException 异常消息远程服务器返回错误: (500) 语法错误无法识别命令。 参考http://www.cnblogs.com/webabcd/archive/2007/01/21/626242.html  KeepAlive - 指定连接是应该关闭还是在请求完成之后关闭默认为true /// summary/// FTP下载文件带进度条/// /summary/// param namefilename/parampublic void DownloadFile(string filename){float percent 0;string filePathName string.Empty;string url string.Empty;filePathName Path.Combine(Application.StartupPath, filename);string dirPath GetDirPath(filePathName);if (!Directory.Exists(dirPath))Directory.CreateDirectory(dirPath);//替换文件目录中的路径为网络路径filename filename.Replace(\\, /);url ftp:// clientUpdateInfo.UpdateFTPIP / clientUpdateInfo.UpdatePath / filename;var reqFtp (FtpWebRequest)FtpWebRequest.Create(new Uri(url));reqFtp.Method WebRequestMethods.Ftp.DownloadFile;reqFtp.UseBinary true;reqFtp.KeepAlive false;//一定要设置此属性否则一次性下载多个文件的时候会出现异常。reqFtp.Credentials new NetworkCredential(clientUpdateInfo.FtpUserName, clientUpdateInfo.FtpUserPwd);var response (FtpWebResponse)reqFtp.GetResponse();long totalBytes response.ContentLength;if (prog ! null){this.BeginInvoke(new MethodInvoker(delegate(){prog.Maximum (int)totalBytes;}));}Stream st response.GetResponseStream();var so new FileStream(filePathName, FileMode.Create);long totalDownloadedByte 0;byte[] by new byte[1024];int osize st.Read(by, 0, (int)by.Length);while (osize 0){totalDownloadedByte osize totalDownloadedByte;so.Write(by, 0, osize);if (prog ! null){this.BeginInvoke(new MethodInvoker(delegate(){prog.Value (int)totalDownloadedByte;}));}osize st.Read(by, 0, (int)by.Length);percent (float)totalDownloadedByte * 1.0f / (float)totalBytes * 100;Application.DoEvents();this.BeginInvoke(new MethodInvoker(delegate(){lbDownInfo.Text 正在下载 filename ,下载进度为: Math.Round(percent, 2) %;lbDownInfo.Refresh();}));Application.DoEvents();}so.Close();st.Close();response.Close();}private void FtpDownload(string filename){string filePathName string.Empty;string url string.Empty;filePathName Path.Combine(Application.StartupPath, filename);string dirPath GetDirPath(filePathName);if (!Directory.Exists(dirPath))Directory.CreateDirectory(dirPath);//替换文件目录中的路径为网络路径filename filename.Replace(\\, /);url ftp:// clientUpdateInfo.UpdateFTPIP / clientUpdateInfo.UpdatePath / filename;FtpWebRequest reqFTP;this.BeginInvoke(new MethodInvoker(delegate(){this.lbDownInfo.Text 开始下载中...;}));FileStream outputStream new FileStream(filePathName, FileMode.Create);reqFTP (FtpWebRequest)FtpWebRequest.Create(new Uri(url));reqFTP.Credentials new NetworkCredential(clientUpdateInfo.FtpUserName, clientUpdateInfo.FtpUserPwd);reqFTP.Method WebRequestMethods.Ftp.DownloadFile;reqFTP.UseBinary true;reqFTP.KeepAlive false;FtpWebResponse response (FtpWebResponse)reqFTP.GetResponse();Stream ftpStream response.GetResponseStream();int bufferSize 1024;int readCount;byte[] buffer new byte[bufferSize];readCount ftpStream.Read(buffer, 0, bufferSize);//FTP上文件的大小int allbye GetFtpFileSize(filename);// (int)response.ContentLength;int startbye 0;this.BeginInvoke(new MethodInvoker(delegate(){this.prog.Maximum allbye;this.prog.Minimum 0;this.prog.Visible true;this.lbDownInfo.Visible true;}));while (readCount 0){outputStream.Write(buffer, 0, readCount);readCount ftpStream.Read(buffer, 0, bufferSize);startbye readCount;this.BeginInvoke(new MethodInvoker(delegate(){this.lbDownInfo.Text 已下载: (int)(startbye / 1024) KB/ 总长度: (int)(allbye / 1024) KB 文件名: filename;prog.Value startbye;this.lbDownInfo.Refresh();}));Application.DoEvents();Thread.Sleep(5);}this.BeginInvoke(new MethodInvoker(delegate(){this.prog.Visible false;this.lbDownInfo.Text 下载成功!;}));ftpStream.Close();outputStream.Close();response.Close();}
http://www.huolong8.cn/news/137618/

相关文章:

  • 深圳市网站建设公开一个设计工作室需要什么
  • 有哪些好的网站建设公司jsp网站开发学习心得
  • 公司网站备案需要什么汕头app开发
  • 网站怎么做404页面宁波网络推广优化公司
  • 做签到的网站苍南配网设计
  • 基于wordpress的英文小游戏站青岛手机网站建设电话
  • 威海哪里可以做网站做seo有什么好处
  • 个人购物网站wordpress 什么值得买 主题
  • 网站开发设计实训实训总结wordpress登录工具
  • 可以做微信推送的网站高校网站建设模板
  • 做粤菜的视频网站宁波网络推广软件
  • 网站搜索功能模块宣传片拍摄协议
  • 一般网站服务费怎么入账做分录博客论坛用wordpress
  • 免费电视剧网站大全在线观看镇江高端网站建设工作室
  • 爱站工具包中国最大的求购平台
  • 企业为什么要做网站 作用是什么wordpress get attachment
  • 网站备案账户名如何查询上海搜索关键词排名
  • 做外贸网站费用公司网站引导页
  • 长春营销型网站设计外籍人士在中国注册公司
  • 长治门户网站公司网站制作专业公司
  • 免费网站百度收录网站首页特效
  • 做网站做系统一样么重庆建网站城选快忻科技悉心
  • 响应式网站建设有利于seo建筑培训
  • 主题资源网站建设模块五作业部门网站建设管理典型经验材料
  • 中交通力建设股份有限公司网站怎么在网站后台做图片新闻
  • 班级网站建设开题报告事业单位建立网站
  • 如何做好网站外链北京网站建设还公司
  • 电商网站建设方案电脑课做网站所需的软件
  • 高端网站开发哪里有什么是seo和sem有什么区别
  • 网站建设可行性的分析池州市建设厅官方网站