以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  ftp上传突然不能用了  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=144693)

--  作者:cd_tdh
--  发布时间:2019/12/27 10:40:00
--  ftp上传突然不能用了

老师,我用按钮通过ftp上传文件,突然不能不用了,麻烦看看什么问题,之前一直正常,而且我通过表格直接点上传,连接都没问题。

Dim dlg As New openFileDialog \'定义一个新的SaveFileDialog
dlg.MultiSelect = True
If dlg.showDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
    Dim ftp1 As new  ftpclient
    ftp1.host=""
    ftp1.Account = ""
    ftp1.password = ""
    Dim r As Row = Tables("采购合同管理").Current
    Dim ls = r.DataRow.Lines("采购合同扫描件")
    For Each f As String In dlg.FileNames
        Dim file = "/采购合同管理/" & r("项目名称") & "/" & r("序号") & "/" & filesys.GetName(f)
        If ftp1.DirExists("/采购合同管理/" & r("项目名称")) = False Then
            ftp1.MakeDir("/采购合同管理/" & r("项目名称"))
        End If
        If ftp1.DirExists("/采购合同管理/" & r("项目名称") & "/" & r("序号")) = False Then
            ftp1.MakeDir("/采购合同管理/" & r("项目名称") & "/" & r("序号"))
        End If
        Dim Result As DialogResult
        If ftp1.FileExists(file) Then
            Result = MessageBox.Show("文件已经存在,是否覆盖?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        End If
        If result = Nothing OrElse result = DialogResult.Yes Then
            If  ftp1.Upload(f,file,True) = True Then
                If ls.contains(file) = False Then
                    ls.add(file)
                End If
            Else
                MessageBox.Show( f & "上传失败" ,"提示" ,MessageBoxButtons.OK,MessageBoxIcon.Question)
            End If
        End If
    Next
    r.DataRow.lines("采购合同扫描件") = ls
    ftp1.Close
End If


--  作者:有点蓝
--  发布时间:2019/12/27 10:44:00
--  
提示什么错误?

For Each f As String In dlg.FileNames
        Dim file = "/采购合同管理/" & r("项目名称") & "/" & r("序号") & "/" & filesys.GetName(f)
msgbox(file )
        If ftp1.DirExists("/采购合同管理/" & r("项目名称")) = False Then
            ftp1.MakeDir("/采购合同管理/" & r("项目名称"))
        End If
msgbox(ftp1.DirExists("/采购合同管理/" & r("项目名称")))
        If ftp1.DirExists("/采购合同管理/" & r("项目名称") & "/" & r("序号")) = False Then
            ftp1.MakeDir("/采购合同管理/" & r("项目名称") & "/" & r("序号"))
        End If
msgbox(ftp1.DirExists("/采购合同管理/" & r("项目名称") & "/" & r("序号")))
        Dim Result As DialogResult
        If ftp1.FileExists(file) Then
            Result = MessageBox.Show("文件已经存在,是否覆盖?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        End If
        If result = Nothing OrElse result = DialogResult.Yes Then
msgbox(f)
            If  ftp1.Upload(f,file,True) = True Then
                If ls.contains(file) = False Then
                    ls.add(file)
                End If
            Else
                MessageBox.Show( f & "上传失败" ,"提示" ,MessageBoxButtons.OK,MessageBoxIcon.Question)
            End If
        End If
    Next

--  作者:cd_tdh
--  发布时间:2019/12/27 10:50:00
--  

找到问题,项目名称里面有“/”符号,谢谢老师

 


--  作者:有点蓝
--  发布时间:2019/12/27 10:53:00
--  
调试方法要学会呀,有问题先看看各个变量输出的结果是否是预期的值。不要每次都要我们给加个msgbox才能找到问题