如何使用Grid View控件从目录下载文件 [英] How to Download Files From Directory Using Grid View control

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

问题描述


在我的Db表中,有4个字段srno,名称,路径,日期时间.在路径字段中完成文件的路径.现在我想使用路径从目录下载文件,当用户单击下载时,它将从数据库获取路径,并从文件夹获取文件以进行下载.请引导我,
感谢全部

Hi,
In my Db Table there are 4 field srno,name,path,date time. Complete Path of file in path field. now i want to download the files from directory using path when the user click on download it will get path from database and file from folder to download it. Plz guide me,
Thank to All

推荐答案

单击下载时是否获得路径.
如果是,则按照以下代码下载文件
您需要获得 System.web.webclient 的帮助.这是代码

Do you get path when you clicks on download.
if yes, then following code to download file
You need to take help of System.web.webclient. here is code

WebClient req=new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer= true;
response.AddHeader("Content-Disposition","attachment;filename=\"" + Server.MapPath(FilePath) + "\"");
byte[] data=req.DownloadData(Server.MapPath(FilePath));
response.BinaryWrite(data);
response.End();



它会提示您保存文件.



it will prompt for saving file.


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

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