客户端一次可上传多个文件,路径存储的数据库里,求在客户端如何实现下载多个文件。string[] strPathList = strPath.Split(';');
int m = 0;
for (int i = 0; i < strPathList.Length; i++)
{
string filePath = "~" + strPathList[i].Remove(0, 2);
if (File.Exists(Server.MapPath(filePath)))
{
m++;
string fileName = Upload.getUpFileName(filePath, "//");
bufferName.Append("<a id='file"+ i.ToString() + "' runat='server' href='" + strPathList[i] + "' target='_blank' >" + m +"、"+fileName + "</a>");
bufferName.Append("<br />");
}
}
Div1.InnerHtml = bufferName.ToString();这里只是实现的超链接下载,有好的方法吗(真正的下载 DownLoadFile)?
int m = 0;
for (int i = 0; i < strPathList.Length; i++)
{
string filePath = "~" + strPathList[i].Remove(0, 2);
if (File.Exists(Server.MapPath(filePath)))
{
m++;
string fileName = Upload.getUpFileName(filePath, "//");
bufferName.Append("<a id='file"+ i.ToString() + "' runat='server' href='" + strPathList[i] + "' target='_blank' >" + m +"、"+fileName + "</a>");
bufferName.Append("<br />");
}
}
Div1.InnerHtml = bufferName.ToString();这里只是实现的超链接下载,有好的方法吗(真正的下载 DownLoadFile)?
解决方案 »
- 在IE6和FIREFOX里面可以正确显示在IE7与8不能正常显示
- 如何通过反射获取Color结构内所定义的所有颜色??
- 创建了一个“项目模板”,在“我的模板“下不能显示,怎么回事???
- 该不该辞职???有点迷茫!!!
- VisualStudioNET安装问题
- 目前是学java还是.net好,各位大虾请进
- 各位高手小弟提个问题? 急啊!!!!希望能得到答复 我现在这里先谢谢了!希望有原代码!!!
- 关于Remoting
- 请教高手,如何做WebForm及WinForm同时使用的打印模块?谢谢!
- 如何在MDI程序中使得用户无法改变子窗体的大小,使得子窗体始终保持到最大化状态?
- 用c#怎么把保存在dbf通用字段里的doc文档读出来
- DllImport遇到的问题
{
String FullFileName = System.Web.HttpContext.Current.Server.MapPath(FileName);
FileInfo DownloadFile = new FileInfo(FullFileName);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.Buffer = false;
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}
你理解错了,客户端相关的文件,点击下载,而文件控件是动态生成的,所以好像不可能调用FileDownload来下载文件。
{
string fname1 = dr["m_name"].ToString();
string DownloadFileName = "~/upfile/" + fname1;
string filepath = Server.MapPath(DownloadFileName);
string filename = Path.GetFileName(filepath);
FileInfo file = new FileInfo(filepath);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
Response.AddHeader("Content-length", file.Length.ToString());
Response.Flush();
Response.WriteFile(filepath);