PDA

Click to See Complete Forum and Search --> : ASP .NET Newbee - Stupid Question


<ABX
Aug 17th, 2003, 10:01 PM
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim dirInfo as New DirectoryInfo(Server.MapPath("/dir1/dir2/"))

articleList.DataSource = dirInfo.GetFiles("*.*")
articleList.DataBind()
End Sub
</script>

<asp:DataGrid runat="server" id="articleList" Font-Name="Verdana"
AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#eeeeee"
HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name"
HeaderText="File Name" />
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time"
ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
<asp:BoundColumn DataField="Length" HeaderText="File Size"
ItemStyle-HorizontalAlign="Right"
DataFormatString="{0:#,### bytes}" />
</Columns>
</asp:DataGrid>


this code works; to an extent. It displays all the files in the directory and links them but it links them to "http://localhost/[filename], but the files are int "http://localhost/dir1/dir2/[filename]"

how do i fix this problem????

<ABX
Aug 18th, 2003, 03:13 PM
Well i created a Virtual Directory and put my aspx page in there and linked it from my main page so i solved my problem.

Is there any way i can get it to only show *.avi , *.wmv , *.mpg and how do i get the links to download by default instead of playing in the browser.