下载的问题,急急急!~ 在asp.net的页面中,点击下载按钮时下载文件并以打包的形式的代码 怎么写啊?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string fileName = "";//客户端保存的文件名 string filePath = Server.MapPath("App_Data/进销存.doc");//路径 //以字符流的形式下载文件 FileStream fs = new FileStream(filePath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream"; //通知浏览器下载文件而不是打开 Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); 导入Io命名空间 string filename = "文件夹/"+name; if (filename != "") { string path = Server.MapPath(filename); FileInfo file = new FileInfo(path); if (file.Exists) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(name)); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "application/octet-stream; charset=gb2312"; Response.Filter.Close(); Response.WriteFile(file.FullName); Response.End(); } } 寻找一个控件,可以在不绑定数据源的条件下输入 在wap中在不用session,cookie的情况下怎么实现登录? 关于连接数 xml查询问题 通过Web Services上传和下载文件 请教高手,有关DataGrid的问题,需详细解答,本人是个菜鸟!!! 哪位高手能为本人提供一份正则表达式的参数表--如有送上50分!!! 对路径“c:\inetpub\wwwroot\fira\en\upload\xxx.gif”的访问被拒绝!何原因?? 网络老师给了道题 关于点击aspxtreelist某一个节点,动态绑定aspxgridview数据 接口可以转换为类? FileUpLoad访问权限问题
string filePath = Server.MapPath("App_Data/进销存.doc");//路径 //以字符流的形式下载文件
FileStream fs = new FileStream(filePath, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Response.ContentType = "application/octet-stream";
//通知浏览器下载文件而不是打开
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
string filename = "文件夹/"+name;
if (filename != "")
{
string path = Server.MapPath(filename);
FileInfo file = new FileInfo(path);
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(name));
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream; charset=gb2312";
Response.Filter.Close();
Response.WriteFile(file.FullName);
Response.End();
}
}