如何设置下载应用程序的内容长度.. [英] How do I set content length for download application..
本文介绍了如何设置下载应用程序的内容长度..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用列表框来显示d个文件。现在我想从列表框中下载文件。
I'm using list box to display d files. Now I want to download the file from list box.
string Files = ListBox1.SelectedValue;
Response.Clear();
Response.BufferOutput = true;
Response.ContentType = "application/exe";
Response.AddHeader("Content-Length", filelength);
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(Files));
Response.End();
推荐答案
假设您的exe文件位于Web应用程序根文件夹内的Downloads文件夹中,然后尝试
assume your exe file located in Downloads folder inside your web application root folder, then try
string fileName =istBox1.SelectedValue;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.TransmitFile(Server.MapPath("~/downloads/" + fileName));
Response.End();
我的文件在服务器中。我正在显示从服务器到列表框的文件。现在我想从列表框中下载它。
文件正在下载,但文件的大小是0字节..
My files are in server. I'm displaying the files from server to list box. Now I want to download it from list box.
the files are downloading but the size of the file is 0 byte..
这篇关于如何设置下载应用程序的内容长度..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文