如何使用ASP.NET下载多个文件 [英] How download more than one file using ASP.NET

查看:72
本文介绍了如何使用ASP.NET下载多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在temp文件夹中有五个文件可供下载该文件。我的目标是下载所有文件,但现在它下载第一个文件。



我尝试过:



我尝试使用此代码下载所有文件

  Dim  strSrcFolder 作为 字符串 = Server.MapPath( 〜/ TempFiles / senthil / PDF / Dim  dinfo  As   DirectoryInfo(strSrcFolder)
对于 每个 finfo As FileInfo In dinfo.GetFiles()
Dim stringFName As String = finfo.Name

Response.ContentType = application / pdf
Response.AppendHeader( Content-Disposition attachment; filename = + HttpUtility.UrlEncode(stringFName,System.Text.Encoding.UTF8))
Response.TransmitFile(Server.MapPath( 〜\TempFiles \senthil \PDF \ + stringFName))
响应。结束()
下一步

解决方案

这是一个很好的解释您所追求的内容的文章:在ASP.NET中下载多个文件 [ ^

I have five file in temp folder for download that file. my aim is download all file but now it download first file.

What I have tried:

I try this code for download all file

Dim strSrcFolder As String = Server.MapPath("~/TempFiles/senthil/PDF/") Dim dinfo As New DirectoryInfo(strSrcFolder) 
For Each finfo As FileInfo In dinfo.GetFiles() 
        Dim stringFName As String = finfo.Name

        Response.ContentType = "application/pdf"
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(stringFName, System.Text.Encoding.UTF8))
        Response.TransmitFile(Server.MapPath("~\TempFiles\senthil\PDF\" + stringFName))
        Response.End()
Next

解决方案

Here's a good article that explains what you're after: Downloading multiple files in ASP.NET[^]


这篇关于如何使用ASP.NET下载多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆