asp.net中有木有关于将一个文件保存到我想要存地址的控件??? 如题,比如我想备份数据库,在备份之前能不能弹出一个保存文件的对话框,将文件保存到我想要的地方?知道有一个FileUpload控件可以上传文件,但不知有没有保存文件的控件呢????求答案!!!!!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //大佬你先帮我解决这我啊!!! 我还要请教啊,上传文件问题。1 --建一个ashx文件(一般处理文件)using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;using NPOI.HSSF.UserModel;namespace 入库管理.ashx{ /// <summary> /// $codebehindclassname$ 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class 下载供应商模板 : IHttpHandler { public void ProcessRequest(HttpContext context) { downloadfile("供应商导入模板.xls");//你下载的文件名: } public bool IsReusable { get { return false; } } //d:\我的文档\Visual Studio 2008\Projects\入库管理\入库管理\ashx\供应商导入模板.xls public void downloadfile(string s_fileName) { string fileName = HttpUtility.UrlDecode(s_fileName); HttpContext.Current.Response.ContentType = "application/x-excel"; string s_path = HttpContext.Current.Server.MapPath("~/OtherFile/") + s_fileName;//这是你要加入你要下载的文件路径 System.IO.FileInfo file = new System.IO.FileInfo(s_path); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());//防止出错 HttpContext.Current.Response.WriteFile(file.FullName); HttpContext.Current.Response.Flush();//发送 HttpContext.Current.Response.Clear();//清缓存 HttpContext.Current.Response.End(); //结束 } }}html 文件中加入就可<a id="aDownLoad" href="ashx/下载供应商模板.ashx" >下载你要导入的模板</a>不明白就追问我。 如何将动态的内容放在body中? 怎么样用程序把excel内的数据导入数据库(SQL SERVER) 我做了一个工程,无意把解决方案删了,只剩下文件代码,请问我该怎么修改?急!~~~ 帮我写写这个路径把 求教电脑路径的正则表达式怎么写?~~~~~我怎么写都不对! 难道真的没人知道吗?关于微软Toolbar? 发布的问题,兄弟们来看~~~ .net显示数据问题,项目的最后一个问题! 向数据库添加大文本数据的问题! 两个问题,对我有一点难度 jQuery ajax json 请教一个关于利用HttpWebRequest访问其他域名的页面写cookie问题,急!谢谢
1 --建一个ashx文件(一般处理文件)using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using NPOI.HSSF.UserModel;namespace 入库管理.ashx
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class 下载供应商模板 : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
downloadfile("供应商导入模板.xls");//你下载的文件名:
} public bool IsReusable
{
get
{
return false;
}
}
//d:\我的文档\Visual Studio 2008\Projects\入库管理\入库管理\ashx\供应商导入模板.xls
public void downloadfile(string s_fileName)
{
string fileName = HttpUtility.UrlDecode(s_fileName);
HttpContext.Current.Response.ContentType = "application/x-excel";
string s_path = HttpContext.Current.Server.MapPath("~/OtherFile/") + s_fileName;//这是你要加入你要下载的文件路径
System.IO.FileInfo file = new System.IO.FileInfo(s_path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());//防止出错
HttpContext.Current.Response.WriteFile(file.FullName);
HttpContext.Current.Response.Flush();//发送
HttpContext.Current.Response.Clear();//清缓存
HttpContext.Current.Response.End(); //结束
}
}
}
html 文件中加入就可<a id="aDownLoad" href="ashx/下载供应商模板.ashx" >下载你要导入的模板</a>不明白就追问我。