就是点击发布目录右边的小按钮出现的。
CellButtonClick代码:
If e.Col.Name = "发布目录" Then
e.Cancel= True
Functions.Execute("刷新listview")
Forms("FTP管理器").open
End If
内部函数代码:
Dim ftp As New FtpClient
ftp.Host="192.168.1.35"
ftp.Account = "tester"
ftp.Password = "tester"
ftp.ChangeDir("/待用户现场确认版本_产线禁止使用/2015") '进入到待用户现场确认版本_产线禁止使用\2015目录
Dim lj As String = "/待用户现场确认版本_产线禁止使用/2015/" & Tables("临时版本跟踪表").current("临时版本编号") & "(" & Tables("临时版本跟踪表").current("客户") & "_" & Tables("临时版本跟踪表").current("博达机型") & ")"
If ftp.DirExists(lj) = False Then '不存在临时版本编号目录时先创建临时版本编号目录
ftp.MakeDir(lj)
End If
Dim ml As String = lj & "/" & Format(Date.now, "yyyy-MM-dd HH-mm-ss")
If ftp.DirExists(ml) = False Then '按照系统时间来创建时间目录
ftp.MakeDir(ml)
End If
Dim lvw As WinForm.ListView = Forms("FTP管理器").Controls("ListView1")
lvw.Rows.Clear
lvw.Images.Clear
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","exe","other"} '定义扩展名数组
Dim kzms As String ="swf accdb mdb psd png xls xlsx bmp rar jpg doc docx zip pdf txt ppt exe" '定义已知扩展名的文本串
For Each ic As String In ics
lvw.Images.AddImage(ic,ic & ".png",ic & ".png") '向listview里添加图标
Next
'==============================以上是设置listview的代码============================
'==============================以下是生成listview的代码============================
Dim sts As List(of String) = ftp.GetFileList(ml)
If sts.Count > 0 Then '若有文件
For Each st As String In sts
Dim r As WinForm.ListViewRow = lvw.Rows.Add '增加一行
Dim Dot As Integer = st.LastIndexOf(".") '定义.的位置
Dim kzm As String = st.SubString(Dot + 1) '获取扩展名
r.text = st
If kzms.Contains(kzm) = True Then '若为已知扩展名
r.ImageKey = kzm '指定行的图标键值
Else
r.ImageKey = "other"
End If
Next
End If