大佬教程收集整理的这篇文章主要介绍了Silverlight文件下载完美版,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
页面:hlink.NavigateUri = new Uri(serviceHelper.baseUrl + servicePath.DownFilePath + "?filename="+((Sys_AttachmentLibrarymodel)selDownFile.SELEctedItem).FileUrl.ToString());
服务端:DownLoadFileHandler.ashx
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.IO; public class DownLoadFileHandler : Baseservice { public override void Processrequest(httpContext context) { Context = context; Result = new ActionResult(); String filename = context.request.QueryString["filename"]; //客户端保存的文件名 filename = httpUtility.UrlDecode(fileName); String filePath = ConfigHelper.UploadPath+ filename; //路径 FileInfo fileInfo = new FileInfo(filePath); if (fileInfo.Exists) { byte[] buffer = new byte[102400]; context.Response.Clear(); FileStream iStream = File.openRead(filePath); long dataLengthToRead = iStream.Length; //获取下载的文件总大小 context.Response.ContentType = "application/octet-stream"; context.response.addheader("Content-Disposition","attachment; filename=" + httpUtility.UrlEncode(filename.SubString(filename.LasTindexOf("\\")+1),System.Text.Encoding.UTF8)); while (dataLengthToRead > 0 && context.Response.IsClientConnected) { int lengthRead = iStream.Read(buffer,Convert.ToInt32(102400));//'读取的大小 context.Response.outputStream.Write(buffer,lengthRead); context.Response.Flush(); dataLengthToRead = dataLengthToRead - lengthRead; } context.Response.Close(); context.Response.End(); } // 输出结果 OutputResult(); } }
以上是大佬教程为你收集整理的Silverlight文件下载完美版全部内容,希望文章能够帮你解决Silverlight文件下载完美版所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。