Vb.net 在gridview中排序文件Creationtime

Vb.net 在gridview中排序文件Creationtime,vb.net,gridview,file-io,Vb.net,Gridview,File Io,我有一个gridview,它从servermappath检索名称和文件creationdatetime的列表,并尝试按creationtime进行排序 Function GetTable() As DataTable Dim filePaths() As String = getFiles(Server.MapPath("~/path/"), "*" + Session("Uauthen") + "*", SearchOption.AllDirectories)

我有一个gridview,它从servermappath检索名称和文件creationdatetime的列表,并尝试按creationtime进行排序

    Function GetTable() As DataTable

        Dim filePaths() As String = getFiles(Server.MapPath("~/path/"), "*" + Session("Uauthen") + "*", SearchOption.AllDirectories)
        Dim tb As New DataTable()
        tb.Columns.Add("FileName")
        tb.Columns.Add("FileCreationTime")
        Dim dv As New DataView(tb)
  dv.Sort = "FileCreationTime DESC"
        Dim sortedDT As DataTable = dv.ToTable()

        'Dim files As List(Of ListItem) = New List(Of ListItem)
        For Each filePath As String In filePaths

            sortedDT.Rows.Add(Path.GetFileName(filePath), File.GetCreationTime(filePath).ToString("d MMM yyyy hh:mm:ss"))


        Next

        Return sortedDT

    End Function

但是gridview上没有发生仍然无法排序的事情还有其他方法可以排序吗

在列中定义变量类型

tb.Columns.Add("FileName", typeof(String))
tb.Columns.Add("FileCreationTime",typeof(DateTime))
DataTable DateTime列排序:


附上示例代码如何获得
文件路径
谢谢Yu Yenkan:),现在我通过重新排列顺序解决了我的问题,并且work@TouchyVivace当前位置请标记为回答帮助您的帖子