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. Advertisements

  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. Advertisements

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. Patrick
    Replies:
    1
    Views:
    937
  2. roopa
    Replies:
    6
    Views:
    1,025
    Jerry Coffin
    Aug 27, 2004
  3. Replies:
    4
    Views:
    2,384
  4. dackz
    Replies:
    0
    Views:
    611
    dackz
    Feb 6, 2007
  5. Debajit Adhikary
    Replies:
    17
    Views:
    958
    Debajit Adhikary
    Oct 18, 2007
  6. OW Ghim Siong
    Replies:
    2
    Views:
    648
    Peter Otten
    Nov 30, 2010
  7. Deepak
    Replies:
    1
    Views:
    170
  8. Fabrizio J Bonsignore
    Replies:
    5
    Views:
    444
    Fabrizio J. Bonsignore syntotic
    Mar 2, 2012
Loading...