Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   display a file list to enable downloading (http://www.velocityreviews.com/forums/t83979-display-a-file-list-to-enable-downloading.html)

Paul Wilson 08-02-2004 09:23 AM

display a file list to enable downloading
 
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==?= 08-02-2004 12:07 PM

RE: display a file list to enable downloading
 
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 (bsb@orcim.com)
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
>
>
>



All times are GMT. The time now is 12:59 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.