易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET文件下载函数

在你的Page_Load中添加这样的代码:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "目的文件名称", @"源文件路径", 1024000);
if (!success)
      Response.Write("下载文件出错!");
Page.Response.End();
文件下载函数代码为:
public static bool ResponseFile(HttpRequest _Request,HttpResponse _Response,string _fileName,string _fullPath, long _speed)
    {
        try
        {
             FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
             BinaryReader br = new BinaryReader(myFile);
            try
            {
                 _Response.AddHeader("Accept-Ranges", "bytes");
                 _Response.Buffer = false;
                long fileLength = myFile.Length;
                long startBytes = 0;
     
                double pack = 10240; //10K bytes
                //int sleep = 200;   //每秒5次    即5*10K bytes每秒
                int sleep = (int)Math.Floor(1000 * pack / _speed) + 1;
 


相关文档:

JSON Serialization and Deserialization in ASP.Net


    
JSON Serialization and Deserialization in ASP.Net
 
I was looking around for a simple example which would just do an object serialization to a JSON format, and then deserializing back to the original object. I found few examples on MSDN, but did seem to be too long ......

ASP.Net全局变量的设置和读取方法

本文介绍两种ASP.Net项目中全局变量使用的方式。web.config文件 和 Gloab文件。以下分别说明:
方法一:web.config文件
——设置:
在web.config文件里添加关键字key是通过<appSettings>标记来实现的,但是appSettings标记通常放在<system.web>.....</system.web>标记外面。例:
<conf ......

将jQuery应用于Asp.net Ajax时,应避免的3个错误

3 mistakes to avoid when using jQuery with ASP.NET AJAX
AJAX, ASP.NET, JavaScript, jQuery By Dave Ward on June 5th, 2008
Over the past few weeks, I think I have definitely embodied Jeff Atwood’s claim that we’re all amateurs, learning together. Despite my best efforts to thoroughly tes ......

Asp.Net下的文件上传功能实现

刚学习.Net没有多长时间,以前都是看别人的文章,学习前辈们的经验和技巧,自己受益匪浅。今天也来个原创的,发个文件上传的代码。主要实现的功能有:1.可以控制允许上传的文件类型;2.上传之后自动以时间命名;3.自动创建上传文件要保存的目录。
不足之处:没有对允许上传的文件大小做限制。其他不足之处还望各位指出,以 ......

asp.net页面生命周期也称执行顺序

1.对象初始化(OnInit方法)
    页面中的控件(包括页面本身)都是在它们最初的FORM中被首次初始化的。通过在ASPX页面的后台代码文件的构造器中声明你的对象,页面将知道对象的类型,并知道需要创建多少个这样的对象。一旦你在构造器中声明了你的控件,你就可以在它的任何子类,方法,事件或者属性中访 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号