use document.execCommand('SaveAs'):<a href="javascript:void(document.execCommand('SaveAs'))">Save As</a>

解决方案 »

  1.   

    saucer(思归)老大 :多谢你的回复,我的目的是想要得到用户想要存储文件的位置,就像用openfile对话框时,可以得到用户想要存储文件的文件夹路径,然后配合System.net.webclient的download函数处理,将特定文件下载到客户端,当然,我也可以要求用户直接输入路径,利用正则表达式限制,但是这样总是不好的吧?能帮我想个更好的办法吗?
    另外,哪位老大知道正则表达式中中文字符的匹配该怎么办?
      

  2.   

    try something like (you might need to use window.open("filedownload.aspx","_blank") when the user clicks on the button)private void Button_Click(object sender, System.EventArgs e)
    {
      //get the file
      string path = Server.MapPath(Request.Params["File"]);
      System.IO.FileInfo file = new System.IO.FileInfo(path);
      Response.Clear();  Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);  Response.AddHeader("Content-Length", file.Length.ToString());  Response.ContentType = "application/octet-stream";
      
      Response.WriteFile(file.FullName);
      
      Response.End();
    }
    Content-Disposition  这一句就是显示SAVE对话框的
      

  3.   

    研究了一下,正则表达式中文字符的匹配和其他差不多:
    例如,匹配文件夹路径的方法(**:\**\**\**\)
    ^[a-zA-Z]:[\\\w]$,
     但是,我还是想通过对话框的形式得到文件夹路径,这样可以避免很多问题,各位老大,帮忙想想?
      

  4.   

    1. not possible to 得到用户想要存储文件的位置 unless you create your own customized browser2. 中文字符的匹配: try (not exactly correct, but close):
    [\u4e00-\u9fff]+
      

  5.   

    System.net.webclient的download函数处理,将特定文件下载到客户端如果你是asp.net 你的这一步也是不能实现的。那样你只能把文件下载到你的服务器上,毕竟你的 代码事实上是在服务器上运行的。如果你的解决方案是使用自己的winform控件,你就不会提以上的问题了(因为那样的话意味着你的概念很清晰,不会也不应该有这种疑惑)。