I'm using this code (as is, fits my needs, may not yours):
Function AgendaListing() As String
Dim DirInfo As New DirectoryInfo("h:\inetpub\naplesclerk\current_agendas\")
Dim Files As FileInfo() = DirInfo.GetFiles()
Dim i As Integer
Dim txtFileList As String = ""
Dim DisplayName As String = ""
Dim TempDate As String = ""
Dim FileYear As String = ""
Dim TempMonthDay As String = ""
Dim FileMonth As String = ""
Dim FileDay As String = ""
Dim CurrentYear As Integer = DatePart("YYYY", Now())
Dim CurrentMonth As Integer = DatePart("M", Now())
Dim CurrentDay As Integer = DatePart("D", Now())
txtFileList = txtFileList & "<ul>"
For i = 0 To Files.Length - 1
TempDate = Left(Files(i).Name, 8)
FileYear = Left(Files(i).Name, 4)
TempMonthDay = Right(TempDate, 4)
FileMonth = Left(TempMonthDay, 2)
FileDay = Right(TempMonthDay, 2)
If DateSerial(CInt(FileYear), CInt(FileMonth), CInt(FileDay)) >= DateSerial(CurrentYear, CurrentMonth, CurrentDay) Then
DisplayName = Replace(Left(Files(i).Name, Len(Files(i).Name) - 4), "_", " ")
txtFileList = txtFileList & "<li><a href=""http://clerk.naplesgov.com/current_agendas/" & Files(i).Name & """>" & DisplayName & "</a></li>"
End If
Next i
txtFileList = txtFileList & "</ul>"
Return txtFileList
End Function
-----
<asp:Label ID="UpcomingAgendas" runat="server" Text="No posted agendas"></asp:Label>
-----
Filenames are formatted as:
yyyymmdd_-_Month_Day_Year_-_Filename.pdf
Sorts by date, displays only those newer than yesterday. Modify as you see fit, feel free to clean it up and if you release it as a module, please make it a free module and email me a copy. I was too lazy to create a real module out of it. :)
Maybe someday I'll have time to fix all the stuff I threw together quickly that became legacy code.
Jeff