代码如下:
Dim path As String = "\" & Tables("项目总表").Current("项目编号") & "\" & tx
Dim lvw As WinForm.ListView = Forms("FTP管理器2").controls("ListView1")
lvw.Font = New Font("宋体",12)'设置字体型号与大小
lvw.StopRedraw() '停止绘制
lvw.Groups.Clear() '清除原来的分组
lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.Details '显示模式为详细信息
lvw.Images.LargeSize = new size(32,32)
Dim ics As String() = {"swf","accdb","mdb","psd","png","xls","xlsx","bmp","rar","jpg","doc","docx","zip","pdf","txt","ppt","pptx","exe","other","dwg","prt","SLDPRT","dxf","eml","stp","step","igs","x_t"} '定义扩展名数组
Dim kzms As String ="swf accdb mdb psd png xls xlsx bmp rar jpg doc docx zip pdf txt ppt pptx exe dwg prt SLDPRT dxf eml stp step igs x_t" '定义已知扩展名的文本串
For Each ic As String In ics
lvw.Images.AddImage(ic,ic & ".png",ic & ".png") '向listview里添加图标
Next
Dim cls() As String = {"文件","修改日期","大小"} '定义列名
Dim wds() As Integer = {350,180,150} '定义列宽
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Name = cls(i) '指定列名
c.Text = cls(i) '指定标题,这里标题和列名相同
c.Width = wds(i) '指定列宽
Next
Dim dls As List(of String)
dls = ftp.GetDetailList(path)
If dls.Count < = 0 Then
Dim r As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
r("文件") = "暂时没有文件"
Else
For Each dl As String In dls
Dim Parts() As String = dl.Split("*")
Dim r As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
Dim Dot As Integer = parts(0).LastIndexOf(".") '定义.的位置
Dim kzm As String = parts(0).SubString(Dot + 1) '获取扩展名
If kzms.Contains(kzm) = True Then '若为已知扩展名
r.ImageKey = kzm '指定行的图标键值
Else
r.ImageKey = "other"
End If
r("文件") = Parts(0)
r("修改日期") = Parts(1)
If parts(2) >1024 Then
r("大小") = format(parts(2)/1048576,"0.0") & "MB"
Else
r("大小") = Parts(2)& "B"
End If
Next
End If
lvw.ResumeRedraw() '恢复绘制
这样做出来后,可以实现显示功能,但是文件显示不是按修改日期顺序来显示的,如图:
有没有办法让他按修改日期来排序显示呢?

此主题相关图片如下:snipaste_2020-08-24_18-12-54.jpg