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";
另外,哪位老大知道正则表达式中中文字符的匹配该怎么办?
{
//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对话框的
例如,匹配文件夹路径的方法(**:\**\**\**\)
^[a-zA-Z]:[\\\w]$,
但是,我还是想通过对话框的形式得到文件夹路径,这样可以避免很多问题,各位老大,帮忙想想?
[\u4e00-\u9fff]+