如题,比如我想备份数据库,在备份之前能不能弹出一个保存文件的对话框,将文件保存到我想要的地方?
知道有一个FileUpload控件可以上传文件,但不知有没有保存文件的控件呢????求答案!!!!!!!!

解决方案 »

  1.   

    //大佬你先帮我解决这我啊!!! 我还要请教啊,上传文件问题。

    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>不明白就追问我。