以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  ftp.GetFileList  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=111080)

--  作者:huhu
--  发布时间:2017/12/14 16:48:00
--  ftp.GetFileList
Dim ftp As New FtpClient
ftp.Host="192.168.1.35"
ftp.Account = "tester"
ftp.Password = "tester"
msgbox(0)------正确弹出
msgbox(vars("zhygwjj"))----弹出显示正确的。

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","gif","doc","docx","zip","pdf","txt","ppt","exe","bin","map","other"}  \'定义扩展名数组
Dim kzms As String ="swf accdb mdb psd png xls xlsx bmp rar jpg  gif doc docx zip pdf txt ppt exe bin map"  \'定义已知扩展名的文本串
For Each ic As String In ics
    lvw.Images.AddImage(ic,ic & ".png",ic & ".png")  \'向listview里添加图标
Next
\'==============================以上是设置listview的代码============================

\'==============================以下是生成listview的代码============================
msgbox(1)----正确弹出
Dim sts As List(of String) = ftp.GetFileList(vars("zhygwjj"))
msgbox(vars("zhygwjj"))-----弹出报错信息。.NET Framework 版本:2.0.50727.7905
Foxtable 版本:2017.10.26.1
错误所在事件:自定义函数listview
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。

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
msgbox(3)---没有弹出。

ftp.Close


注:系统一直用的好好的,不知道今天怎么就报报错。请分析一下会是什么问题?

--  作者:有点甜
--  发布时间:2017/12/14 16:55:00
--  

这个变量 vars("zhygwjj") 换一个名字试试

 

或者使用临时变量

 

msgbox(vars("zhygwjj"))----弹出显示正确的。

dim lsbl = vars("zhygwjj") \'后面都用 lsbl


--  作者:huhu
--  发布时间:2017/12/14 17:02:00
--  
Dim sts As List(of String) = ftp.GetFileList(vars("zhygwjj"))
msgbox(vars("zhygwjj"))-----弹出报错信息。.NET Framework 版本:2.0.50727.7905
Foxtable 版本:2017.10.26.1
错误所在事件:自定义函数listview
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。


出错的是这个
Dim sts As List(of String) = ftp.GetFileList(vars("zhygwjj"))
msgbox(vars("zhygwjj"))----这个出错。



然后换成Dim lsbl = vars("zhygwjj")也报同样的错误。未将对象引用设置到对象实例。

--  作者:有点甜
--  发布时间:2017/12/14 17:10:00
--  

在正常弹出的地方设置变量

 

msgbox(vars("zhygwjj"))----弹出显示正确的。

dim lsbl = vars("zhygwjj")