下载代码说明 [英] downlaod code explanation

查看:116
本文介绍了下载代码说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释这段代码

can anyone please explain this code

if (e.CommandName == "download")
            {
                string filename = e.CommandArgument.ToString();
                string path = MapPath("~/Docfiles/" + filename);
                byte[] bts = System.IO.File.ReadAllBytes(path);
                Response.Clear();
                Response.ClearHeaders();
                Response.AddHeader("Content-Type", "Application/octet-stream");
                Response.AddHeader("Content-Length", bts.Length.ToString());
                Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
                Response.BinaryWrite(bts);
                Response.Flush();
                Response.End();
            }







什么是命令参数,mappath,以及这是什么

Content-Type,Application / octet-stream






what is command argument, mappath, and also what is this
"Content-Type", "Application/octet-stream"
and also

Response.AddHeader("Content-Length", bts.Length.ToString());
                Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
                Response.BinaryWrite(bts);
                Response.Flush();

推荐答案

e.CommandName 是一个命令参数,与任何控件相关联,例如Button,ImageButton等。

此外,在编写代码时,您会找到这些控件的 CommandName 属性。所以它只是在点击控件时执行的消息(参数)



关于内容 - 键入,Application / octet-stream,这是 MIME - 多用途Internet邮件扩展,是一个互联网标准,用于描述各种文件的内容。

您可以看到大量的扩展此处 [ ^ ]及其文件类型。



-KR
e.CommandName is a command argument, which is associated with any control i.e Button, ImageButton etc.
In addition, you would find CommandName property for these controls while writing the code. So it is nothing but the message(argument) that gets executed when control is clicked.

And about the "Content-Type", "Application/octet-stream" , this is the MIME - Multipurpose Internet Mail Extensions, is an internet standard that is used to describe the contents of various files.
You can see plenty of extension over here[^] with its file type.

-KR


这篇关于下载代码说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆