以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  崩溃了,奇怪的错误  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=127658)

--  作者:newsun2k
--  发布时间:2018/11/19 14:52:00
--  崩溃了,奇怪的错误
If ftp1 Is Nothing Then Return False
If ftp1.Connected = False Then Return False
If filesys.FileExists(strLocalFile) Then filesys.DeleteFile(strLocalFile,2,2)
If ftp1.FileExists(strRemoteFile) Then
    If ftp1.Download(strRemoteFile,strLocalFile) = False Then
msgbox(ftp1.Connected)                                                              ‘此处报false
        msgbox(strRemoteFile)
        msgbox(strLocalFile)

。。。。。

我晕了,开发环境下,没问题,一发布就出错,导致无法下载文件。

--  作者:有点甜
--  发布时间:2018/11/19 15:04:00
--  

1、ftp信息发上来;

 

2、测试代码发上来。


--  作者:newsun2k
--  发布时间:2018/11/19 15:32:00
--  
局域网内的ftp,代码成这样:
strRemoteFile = "/升级文件/" & dr("文件名")
strLocalFile = Vars("_gsTempPath") & "\\" & dr("文件名")
If filesys.FileExists(strLocalFile) Then filesys.DeleteFile(strLocalFile,2,2)
Dim ftp1 As new ftpclient
ftp1.host = Vars("_gsFtpHostAdmin")
ftp1.Account = Vars("_gsFtpAccountAdmin")
ftp1.Password =  Vars("_gsFtpPasswordAdmin")
ftp1.UTF8 = True

If ftp1 Is Nothing Then Return False
If ftp1.Connected = False Then ftp1.Connect
If ftp1.FileExists(strRemoteFile) Then
msgbox(ftp1.Connected)                                                  报True
msgbox(strRemoteFile)                                                    报/升级文件/升级包20181202.zip
msgbox(strLocalFile)                                                        报F:\\编程\\xxx管理系统\\Publish\\project\\temp\\升级包20181202.zip
    If ftp1.Download(strRemoteFile,strLocalFile) = False Then
msgbox(ftp1.Connected)                                              报False
        MessageBox.show("升级包下载失败!","提示",MessageboxButtons.Ok,MessageboxIcon.Information)                    报升级包下载失败
        ftp1.close
        Return False
    End If
Else
    MessageBox.show("下载失败,升级文件包不存在!","提示",MessageboxButtons.Ok,MessageboxIcon.Information)
    ftp1.close
    Return False
End If


--  作者:newsun2k
--  发布时间:2018/11/19 15:35:00
--  
发布后才出错,开发情况下,把文件正常down回来了。
--  作者:有点甜
--  发布时间:2018/11/19 15:42:00
--  
以下是引用newsun2k在2018/11/19 15:35:00的发言:
发布后才出错,开发情况下,把文件正常down回来了。

 

1、用【管理员身份】运行exe文件;

 

2、执行访问ftp的时候,防火墙有可能弹出是否允许连接公网的窗口,你要点允许;

 

3、发布前发布后,在同一台电脑测试的吗?尽量在同一台电脑测试。

 

4、发布一个新的项目,测试对应代码,看是否也这样。如果也是,新项目发上来测试。


--  作者:newsun2k
--  发布时间:2018/11/19 15:45:00
--  
1、试了,不行
2、没有
3、同一台电脑,我是在自己电脑,publish这个目录下直接执行的。
4、稍等

--  作者:newsun2k
--  发布时间:2018/11/19 18:10:00
--  
试了半天;下面这句改一下
 If ftp1.Download(strRemoteFile,strLocalFile) = False Then
改成
 If ftp1.Download(strRemoteFile,“F:\\编程\\xxx管理系统\\Publish\\project\\temp\\升级包20181202.zip”) = False Then
就好了。没问题。
msgbox(strLocalFile = "F:\\编程\\xxx管理系统\\Publish\\project\\temp\\升级包20181202.zip") 返回true
无语的很。
这个文件名必须要拼一下,不能写死。


--  作者:有点甜
--  发布时间:2018/11/19 18:15:00
--  

 

是不是你temp文件夹没有建立?如果对应文件夹不存在,有可能报错的。

 


--  作者:newsun2k
--  发布时间:2018/11/19 18:32:00
--  
解决了