以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  帮忙看看这段代码错哪里了?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=73300)

--  作者:jinzhengbe
--  发布时间:2015/8/16 14:52:00
--  帮忙看看这段代码错哪里了?

帮忙看看这段代码错哪里了?

 

Dim ftp As New FtpClient
ftp.Host="tangrenjie.net"
ftp.Account = "jinzhengbe"
ftp.Password = "Huayin7761"
For Each File As String In FileSys.GetFiles("c:\\as\\")
    If ftp.Upload("file,"\\aa\\" ") = True Then
    Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

End If

Next

 

 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图.png
图片点击可在新窗口打开查看

 

 


--  作者:大红袍
--  发布时间:2015/8/16 14:54:00
--  
If ftp.Upload(file, "/aa/" & FileSys.GetName(file)) = True Then
--  作者:jinzhengbe
--  发布时间:2015/8/16 19:31:00
--  

非常感谢~~这个问题解决了

 

但是又出来一个问题, 每上传一个文件 就提示 上传成功,  不能等所有文件都上传完 才提示么?


--  作者:有点蓝
--  发布时间:2015/8/16 19:37:00
--  

改一下

Dim hasFalse as boolean =false

For Each File As String In FileSys.GetFiles("c:\\as\\")
    If ftp.Upload("file,"\\aa\\" ") = True Then      
    Else
    hasFalse = true


End If

Next

if hasFalse then

Messagebox.show("有文件上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

else

Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

end if

[此贴子已经被作者于2015/8/16 19:37:08编辑过]

--  作者:jinzhengbe
--  发布时间:2015/8/16 20:39:00
--  
非常感谢 但是好像有点问题,有其他办法么? 文件传不上去
[此贴子已经被作者于2015/8/16 20:45:10编辑过]

--  作者:有点蓝
--  发布时间:2015/8/16 20:47:00
--  

Dim hasFalse as boolean =false

For Each File As String In FileSys.GetFiles("c:\\as\\")
    
If ftp.Upload(file, "/aa/" & FileSys.GetName(file)) = True  Then      
    Else
    hasFalse = true


   End If

Next

这一段用你改过的那段


--  作者:lmk
--  发布时间:2015/8/16 21:27:00
--  
这样会不会相对合理一些呢

Dim ftp As New FtpClient
ftp.Host="tangrenjie.net"
ftp.Account = "jinzhengbe"
ftp.Password = "Huayin7761"
Dim Result As DialogResult
For Each File As String In FileSys.GetFiles("c:\\as\\")
    If ftp.Upload(file, "/aa/" & FileSys.GetName(file)) = False Then
        Result = Messagebox.show(FileSys.GetName(file) & "上传失败!是否继续上传剩余文件?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information)
        If Result = 6 Then
            Continue For
        Else
            Exit For
        End If
    End If
Next
If Result = 0 Then
    Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If