===在C#里如何通过按钮点击然后提取文件=== 比如我d:下有一个文件“AA”,我该如何通过按钮点击,然后在WEB页面上弹出那种打开保存界面供用户下载这个文件? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected void Download_Click(object sender, ImageClickEventArgs e) { try { string url = this.Server.MapPath(this.DrivePath); string fielName = this.DrivePath.Substring(this.DrivePath.LastIndexOf("//") +2); //Response.Write("<script>alert('daf');</script>"); //this.lblMessage.Text = url + "aaa" + fielName; long speed = UtilTool.ToSafeInt32(ConfigurationManager.AppSettings["Speed"]); bool download = new DownLoad().ResponseFile(this.Request,this.Response,fielName,url,speed); //if (download) //{ // this.lblMessage.Text = "11111111111111111111111111111111111111111111111111111!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; // Response.Write("<script>alert('下载完成!');window.opener = null;window.close();</script>"); // Response.Write("<script>alert('成功!!');</script>"); //} } catch (Exception ex) { this.lblMessage.Text = ex.Message; } }点击后自己就出现保存到那里。 有可能你安装的下载软件也就出来。自己选用那个下载 你贴的这个,不行吧,download()这个是哪里的函数,我是在WEB上的编程阿 Response.Clear(); FileStream fs = File.Open(Server.MapPath(filePath), FileMode.Open);byte[] bs = new byte[fs.Length];fs.Read(bs,0,bs.Length-1);System.Text.UTF8Encoding uen = new System.Text.UTF8Encoding();char[] cs = uen.GetChars(bs);Response.Write(cs, 0, cs.Length); 当超级连接目标为浏览器不能识别的文件格式时,就自动生成下载连接所以:<a href=xxx.zip></a>就可以了 为什么我在DataGridView里面显示的都挤在一个单元格里了? C#索引器问题 BSD 请问如何动态的将服务端上的类加载到客户端的程序上,并动态加载 如何在winform程序中判断一个窗体的存在 与sql连接后运行程序sql产生的问题 请教一下C#中API动态库函数的声明的几个问题 复制、粘帖问题 能不能把c#做的web程序转成html,有没有这方面的软件呢? 如何开发用户控件? 为什么"在位置 0 处没有任何行。"啊 很急啊 啊 C#可以问吗? 计算工资系统不知道那里错了,越算越少的,谁能帮我?拜托了各位
{
try
{
string url = this.Server.MapPath(this.DrivePath);
string fielName = this.DrivePath.Substring(this.DrivePath.LastIndexOf("//") +2);
//Response.Write("<script>alert('daf');</script>");
//this.lblMessage.Text = url + "aaa" + fielName;
long speed = UtilTool.ToSafeInt32(ConfigurationManager.AppSettings["Speed"]);
bool download = new DownLoad().ResponseFile(this.Request,this.Response,fielName,url,speed);
//if (download)
//{
// this.lblMessage.Text = "11111111111111111111111111111111111111111111111111111!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
// Response.Write("<script>alert('下载完成!');window.opener = null;window.close();</script>");
// Response.Write("<script>alert('成功!!');</script>");
//}
}
catch (Exception ex)
{
this.lblMessage.Text = ex.Message;
}
}
点击后自己就出现保存到那里。 有可能你安装的下载软件也就出来。自己选用那个下载
Response.Clear();
FileStream fs = File.Open(Server.MapPath(filePath), FileMode.Open);
byte[] bs = new byte[fs.Length];
fs.Read(bs,0,bs.Length-1);
System.Text.UTF8Encoding uen = new System.Text.UTF8Encoding();
char[] cs = uen.GetChars(bs);Response.Write(cs, 0, cs.Length);
所以:
<a href=xxx.zip></a>
就可以了