title: VB.NET Directory.GetFiles Sort by Date
body: <p>I have a directory of Xml files. How do I grab only the files that have been created in the last 30 days and sort them in ascending order? I am not bound to using Directory.GetFiles if there is a more efficient solution.</p>
  
  <p>I then create and bind a list of files to a gridView in which I need both the File Name and Path. I display the File Name and use the Path value in the RowDataBound event to build a HyperLink to the file.</p>
  
  <p>Thanks! \m/ \m/</p>
  
  <pre><code>Dim filePaths() As String = Directory.GetFiles("C:\XmlFiles\")
  Dim files As List(Of ListItem) = New List(Of ListItem)
  
  For Each filePath As String In filePaths
      files.Add(New ListItem(Path.GetFileName(filePath), filePath))
  Next
  
  gv.DataSource = files
  gv.DataBind()
  </code></pre>