嗨,如何在asp.net页面中显示文件夹并下载该文件夹内容? [英] hi how to display folders in asp.net page and download that folder content?
本文介绍了嗨,如何在asp.net页面中显示文件夹并下载该文件夹内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi如何在asp.net页中显示文件夹并下载文件夹内容?
该文件夹保存在项目中,我的意思是我在project ..中创建了文件夹,所以我想在页面中显示该文件夹并下载该文件..
谁能建议我该怎么做?.
感谢和问候
sheikh
hi how to display folders in asp.net page and donwload folder content?
that folder saved in project i mean i created folders in project.so that folder i want to show in page and download that files..
can any one suggest me how to do this..
thanks and regards
sheikh
推荐答案
检查以下内容:
显示特定文件夹的文件并允许用户下载它们 [使用DataGrid在目录中显示文件 [
Check This:
Displaying the files for a specific folder and allow the user to download them[^]
Displaying the Files in a Directory using a DataGrid[^]
我在下面显示了文件夹中的所有文件方式
首先创建中继器
i show the all files in the folder in following way
first create Repeater
<asp:repeater id="rptrFiles" runat="server" onitemcommand="rptrFiles_ItemCommand">
<itemtemplate>
<tr style="background-color: #f5f5f5; height: 20px;">
<td align="left" style="padding-removed 15px;">
<asp:linkbutton id="LinkButton1" commandname="download" commandargument="<%# Eval("FullName")%>">
runat="server" Style="text-align: center;" Text='<%# Eval("Name")%>' />
</asp:linkbutton></td>
</tr>
</itemtemplate>
</asp:repeater>
在cs之后写绑定
after in cs write the binding
private void GetFilesAndFolder()
{
DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/FileUpload/ZipFile"));
FileInfo[] file = dir.GetFiles("*", SearchOption.AllDirectories);
rptrFiles.DataSource = file;
rptrFiles.DataBind();
}
然后
and then
protected void rptrFiles_ItemCommand(object source, RepeaterCommandEventArgs e)
{
string fullpath = e.CommandArgument.ToString();
string path = Path.GetFileName(fullpath);
string data = "~/FileUpload/ZipFile/" + @"/" + path;
Response.Redirect(data);
}
它将下载文件夹的内容.
现在,您可以依靠它来显示文件夹或thar perticular文件夹中的文件了
感谢U
@Chetanv @
it will download the content of folder.
now its your depend to show the files in the folder or thar perticular folder
Thank U
@Chetanv@
这篇关于嗨,如何在asp.net页面中显示文件夹并下载该文件夹内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文