inet控件实现ftp下载,但下载有时不成功,程序直接结束,请帮忙。

u011381970 2014-01-09 05:54:06
源代码如下:(希望解决的问题1、提供list表单,将登录ftp路径下的文件或文件夹显示出来;2、增加下载的判断,特别是下载完一个文件后程序不在有动作了再下载下一个文件。)折腾好几天了,还没搞定。先谢谢了。

Private Sub Command1_Click()
Dim report_date As Date '定义公共日期
Dim check_i As Integer
check_i = 1
Dim path_hd As String '定义读取路径
Dim path_namehd As String '定义名字
Dim hdfile_head As String
path_hd = "//hd/"
hdfile_head = "HD"
path_namehd = "邯郸公司"
report_date = DTPicker1.Value - 1
Call check_report(path_hd, path_namehd, report_date, hdfile_head, check_i)
End Sub

Sub check_report(path As String, name As String, pre_date As Date, file_head As String, excel_i As Integer)
Dim str_together As String
Dim filehead_together As String
Dim reach_record As String
Dim disreach_record As String
filehead_together = filehead_together + Format(pre_date, "YYYYMMDD")
str_together = path + Format(pre_date, "YYYYMMDD")
'Debug.Print str_together
Inet1.URL = "192.168.2.11/"
Inet1.UserName = "xiexie"
Inet1.Password = "zhbxst"
onerr goto Proc_Exit:
Inet1.AccessType = icUseDefault '设置与Internet连接的类型,默认值
Inet1.Protocol = icFTP
Inet1.RemotePort = 21
Inet1.Cancel
On Error GoTo Proc_Exit

Inet1.Execute Inet1.URL, "dir " & "/"

Do While Inet1.StillExecuting
DoEvents
Loop

Inet1.Execute Inet1.URL, "GET " & str_together & ".xls " & App.path & "\" & file_head & filehead_together & ".xls"
Do While Inet1.StillExecuting
DoEvents
Loop

If Dir(App.path & "\" & file_head & filehead_together & ".xls") = "" Then
Open App.path & "\jkrb.txt" For Append As #1
Print #1, reach_record
Close #1
Else
disreach_record = disreach_record + name & "jkrb"

Open App.path & "\jkrb.txt" For Append As #1
Print #1, disreach_record
Close #1
End If
Proc_Exit:
If Err.Number = -2147467259 Then
' Resume
MsgBox "数据库连接失败,请检查网络环境,程序退出!!~", 16, "错误"
End
'Fpross.StatusBar1.Panels(1) = "数据库连接失败!"
ElseIf Err.Number = 35754 Then
MsgBox "FTP服务器连接失败,请检查网络环境,程序退出!", 16, "错误"
End


End If

End Sub
...全文
167 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lentoo 2014-01-10
  • 打赏
  • 举报
回复
谢谢分享,学习一下。
u011381970 2014-01-09
  • 打赏
  • 举报
回复
比较着急,高手指教一下。
u011381970 2014-01-09
  • 打赏
  • 举报
回复
自己顶一下吧。

1,453

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧