Click here to Skip to main content
15,904,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

i show the all files in the folder in following way

first create Repeater

C#
<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>



after in cs write the binding
C#
private void GetFilesAndFolder()
    {
        DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/FileUpload/ZipFile"));
        FileInfo[] file = dir.GetFiles("*", SearchOption.AllDirectories);
        rptrFiles.DataSource = file;
        rptrFiles.DataBind();
    }



and then


C#
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);

    }


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@
 
Share this answer
 
v2
Comments
ythisbug 1-Mar-12 0:32am    
hi bro xmlns:asp="#unknown" y we have to declare this??
ythisbug 1-Mar-12 0:34am    
error creating rptrFiles this does not have a public property named xmnls:asp
ythisbug 1-Mar-12 0:56am    
not like this type of examples.i want to show folders from application and i want to download tat files directly in my desktop.not in application..
[no name] 2-Mar-12 4:26am    
sorry xmlns:asp="#unknown" it is not part of code.
by mistake it will paste.
 
Share this answer
 
Comments
ythisbug 1-Mar-12 0:05am    
thanks.bro m using c# language i don knw vb
ythisbug 1-Mar-12 0:15am    
Compiler Error Message: CS0428: Cannot convert method group 'GetFiles' to non-delegate type 'System.IO.FileInfo[]'. Did you intend to invoke the method?

hi m getting this error..what namespace should i delcare??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900