你的文件保存在数据库还是独立文件?
解决方案 »
- 紧急!word转为HTML生成的垃圾代码怎么消除?
- 谁能告诉我 这个怎么做啊
- 多张表数据绑定到同一个GridView中,而且有部分字段不一样
- js生成html ,後臺獲取html發送郵件,郵件格式問題
- RadioButtonList的烦心事,散分了
- 急切等待给分!!网站中aspx文件不能在多个.dll文件中吗?
- iewebcntrols控件 在2000server服务器treeview显示问题.
- 声明数组问题
- 交流交流!谢谢大家!(分页问题)
- 框架中页面的退出问题。。。
- 请问,怎样在.net的webform中引入windows mediaplayer?
- 我想取30位的随机数?怎么写函数?这样写对吗?
谢谢。
private void cmdDown_Click(object sender, System.EventArgs e)
{
string filename1=ddlWJLX.SelectedItem.Value+".doc";//文件名
string filename2=HttpUtility.UrlEncode( System.Text.Encoding.UTF8.GetBytes(ddlWJLX.SelectedItem.Text+".doc"));//保存对话框中显示的中文文件名
string filepath=Path.Combine(Server.MapPath("files"),filename1);//文件路径
if(File.Exists(filepath))
{
Response.Buffer=true;
Response.Clear();
Response.ContentType="application/octet-stream";
Response.AddHeader("Content-Disposition","attachment; filename="+filename2+";");
Response.WriteFile(filepath);
Response.Flush();
Response.End();
}
else
{
lblMesg.Text="对不起,文件不存在,无法下载!";
}
}