如何创建链接按钮从文件夹下载所有pdf文件 [英] How I can create link button to download all pdf files from folder

查看:97
本文介绍了如何创建链接按钮从文件夹下载所有pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击下载按钮应该从路径下载所有文件



它只下载一个pdf文件,我想下载所有的pdf文件

或它自己的文件夹



我尝试过的事情:



when i click on download button should download all the files from the path
but
it's download only one pdf file and i want to download all the pdf files
or the folder it's self

What I have tried:

string[] file = Directory.GetFiles(@"C:\Users\IBRAHIM\Desktop\ResultFile\export\" + Session["userTrans"] + "", "*.PDF", SearchOption.AllDirectories);

                foreach (string namefile in file)
                {
                    FileInfo fileinfo = new FileInfo(namefile);
                    lbErrorResult.Text = fileinfo.ToString();
                    Response.Clear();
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileinfo.Name);
                    Response.Buffer = true;
                    //Response.Write(file);
                    Response.WriteFile(fileinfo.FullName);
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.End();
                    Response.Close();
                }

推荐答案

谷歌:html下载多个文件 [ ^ ]



这需要您在页面中编写javascript代码来管理和启动要下载的每个文件。
Google: "html download multiple files"[^]

This requires you write javascript code into your page to manage and kick-off each file to be downloaded.


这篇关于如何创建链接按钮从文件夹下载所有pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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