aspx folder list

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

i am trying to write an aspx page that will list all the folders in a
directory containing a list of albums (this is a virtual directory on
the web server). each folder contains a picture called folder.jpg
i would like to display the picture and the name of the folder in a
list, and if there are any files, list them - like the 'My Music'
folder in Windows XP
anybody know how to do this easily? if somebody could post the code,
it would be much aprecialted!
thanks,
Rob
 
another problem on top of this, not all of the folders have the image
in, but a subfolder in that folder will have. i'd like to just use one
of them.
this is what i have so far:

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.IO" %>
<script runat="server">

Sub Page_Load(sender as Object, e as EventArgs)
Dim strPath As String = "r:\MP3's\"
Dim myDirInfo As DirectoryInfo


myDirInfo = New DirectoryInfo(strPath)

dgFileList.DataSource = myDirInfo.GetDirectories()
dgFileList.DataBind()
End Sub

</script>
<html>
<head>
<title>ASP.NET Directory List Sample</title>
</head>
<body>
<p>
<asp:DataGrid id="dgFileList" runat="server"
AutoGenerateColumns="False" ItemStyle-BackColor="#CCFFCC"
HeaderStyle-Font-Bold="True" HeaderStyle-ForeColor="#FFFFFF"
HeaderStyle-BackColor="#006600" CellPadding="0" CellSpacing="0"
BorderColor="white" Border="0" BackColor="White">
<HeaderStyle font-bold="True" horizontalalign="Center"
forecolor="White" backcolor="Gray"></HeaderStyle>
<AlternatingItemStyle
backcolor="#E0E0E0"></AlternatingItemStyle>
<ItemStyle backcolor="White"></ItemStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Image ID="imgSmall" Runat="server"
Width="50" Height="50" ImageUrl='<%# "/MP3/" &
DataBinder.Eval(Container.DataItem,"Name") & "/folder.jpg" %>'
</asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
<asp:HyperLinkColumn DataNavigateUrlField="Name"
DataNavigateUrlFormatString="MP3/{0}" DataTextField="Name"
HeaderText="File Name:"></asp:HyperLinkColumn>
</Columns>
</asp:DataGrid>
</p>
</body>
</html>
 
Back
Top