display a file list to enable downloading

Discussion in 'ASP .Net' started by Paul Wilson, Aug 2, 2004.

  1. Paul Wilson

    Paul Wilson Guest

    How do i display the list of files in a particular directory (only the file
    name), in a grid or similar control, with hyperlinks to be able to download
    those files.

    Regards,
    Paul
    Paul Wilson, Aug 2, 2004
    #1
    1. Advertising

  2. Hi Paul,

    U can use the DirectoryInfo.GetFiles() method to get the list of files in the directory and then bind the result to a datagrid. Here's some sample code:

    //to be put in the codebehind file
    DirectoryInfo di=new DirectoryInfo("C:\\");
    FileInfo[] fi=di.GetFiles();
    DataGrid1.DataSource=fi;
    DataGrid1.DataBind();

    //in the aspx file
    <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns=false>
    <Columns>
    <asp:BoundColumn HeaderText="Name" DataField="Name"/>
    <asp:BoundColumn HeaderText="Date Created" DataField ="CreationTime" />
    </Columns>
    </asp:DataGrid>


    --
    Bharat Biyani ()
    http://www.orcim.com



    "Paul Wilson" wrote:

    > How do i display the list of files in a particular directory (only the file
    > name), in a grid or similar control, with hyperlinks to be able to download
    > those files.
    >
    > Regards,
    > Paul
    >
    >
    >
    =?Utf-8?B?QmhhcmF0IEJpeWFuaQ==?=, Aug 2, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ABC
    Replies:
    1
    Views:
    1,170
    Brock Allen
    Oct 7, 2005
  2. Patrick
    Replies:
    1
    Views:
    646
  3. Replies:
    4
    Views:
    2,134
  4. Deepak
    Replies:
    1
    Views:
    103
  5. Fabrizio J Bonsignore
    Replies:
    5
    Views:
    313
    Fabrizio J. Bonsignore syntotic
    Mar 2, 2012
Loading...

Share This Page