più correttamente con il 2005 sarebbe ad esempio se devi elencarlo su una check
codice:
Public Sub CaricaFileXml()
rbNewsToMail.Items.Clear()
Dim fileInfos() As System.IO.FileInfo
Dim dirInfo As New System.IO.DirectoryInfo(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath & "Public\MyPublic\")
fileInfos = dirInfo.GetFiles("*.xml")'miotipo
Dim fInfo As New System.Collections.Generic.List(Of System.IO.FileInfo)()
fInfo.AddRange(fileInfos)
fInfo.Sort(New FileDateSorter())
For Each f As System.IO.FileInfo In fInfo
Dim xi As New ListItem(( f.Name.Remove(f.Name.LastIndexOf(".")) ), f.Name)
MiaCheck.Items.Add(xi)
Next
End Sub
e la classe
codice:
Class FileDateSorter : Implements Generic.IComparer(Of System.IO.FileInfo)
Public Function Compare(ByVal x As System.IO.FileInfo, ByVal y As System.IO.FileInfo) As Integer Implements System.Collections.Generic.IComparer(Of System.IO.FileInfo).Compare
Return Date.Compare(x.LastWriteTime, y.LastWriteTime)
End Function
End Class
Antonio F.