关于连接ftp的问题,在线等,急!!!急!!!急!!!
//一个函数的作用,去ftp上取图像Public Function ProcessDocTask() As Long
frmBatchProcess.InetRecon.url = "ftp://" & m_szFTPUser & ":" & m_szFTPPassword & "@" & m_szFTPServerName
isBusy = True
frmBatchProcess.InetRecon.Execute , "get " & szImagePath & " " & Chr(34) & szTempPath & Chr(34)
writeSealLog "ENDETGETIMAGE", "", "", ""
Do While isBusy
isBusy = frmBatchProcess.InetRecon.StillExecuting
DoEvents
Loop
End Function
//定时器的作用
Private Sub Timer2_Timer()
On Error GoTo errorHandle
m_Timer = m_Timer + 1
If m_Timer > 5 Then
InetRecon.Execute , "CLOSE" '关闭ftp连接
m_Timer = 0
End If
Exit Sub
errorHandle:
MsgBox Err.Description, vbExclamation, "错误提示"
End
End Sub
现在是这样的,我想使这两个里的InetRecon.Execute方法中如何確保Server已完成第一個 Request(cd ) 後再執行第二個(get) 就是说互不影响,
网上有个帖子说在两个
兩個Request加入下列程式碼
While Inet1.StillExecuting
DoEvents
Wend
问题就解决了,但是我不太明白,在我的代码里怎么加,谁能指点一下啊?感激不尽! --------------------编程问答-------------------- 咋没人回复 啊? --------------------编程问答-------------------- ProcessDocTask() 中已经有 isBusy 标记当前正在执行;
那么在 Timer2_Timer() 中判断一下是否 isBusy,是就跳出,等待下次定时再进行尝试。 --------------------编程问答-------------------- Private Sub Timer2_Timer()
On Error GoTo errorHandle
m_Timer = m_Timer + 1
While Inet1.StillExecuting
DoEvents
Wend
If m_Timer > 5 Then
InetRecon.Execute , "CLOSE" '关闭ftp连接
m_Timer = 0
End If
Exit Sub
errorHandle:
MsgBox Err.Description, vbExclamation, "错误提示"
End
End Sub
这样写可以吗?
--------------------编程问答--------------------
Private Sub Timer2_Timer()--------------------编程问答-------------------- 我这样写对不?先判断ProcessDocTask() 里的InetRecon.StillExecuting 如果正在Execute那么在timer2中就不执行CLOSE了
On Error GoTo errorHandle
m_Timer = m_Timer + 1
If m_Timer > 5 Then
InetRecon.Execute , "CLOSE" '关闭ftp连接'
if isbusy then exit sub '<-
m_Timer = 0
End If
Exit Sub
errorHandle:
MsgBox Err.Description, vbExclamation, "错误提示"
End
End Sub
Private Sub Timer2_Timer()
On Error GoTo errorHandle
m_Timer = m_Timer + 1
If m_Timer > 5 Then
if InetRecon.StillExecuting then exit sub '<-
InetRecon.Execute , "CLOSE" '关闭ftp连接'
m_Timer = 0
End If
Exit Sub
errorHandle:
MsgBox Err.Description, vbExclamation, "错误提示"
End
End Sub --------------------编程问答-------------------- 我这样写对不?先判断ProcessDocTask() 里的InetRecon.StillExecuting 如果正在Execute那么在timer2中就不执行CLOSE了
Private Sub Timer2_Timer()
On Error GoTo errorHandle
m_Timer = m_Timer + 1
If m_Timer > 5 Then
if InetRecon.StillExecuting then exit sub '<-
InetRecon.Execute , "CLOSE" '关闭ftp连接'
m_Timer = 0
End If
Exit Sub
errorHandle:
MsgBox Err.Description, vbExclamation, "错误提示"
End
End Sub --------------------编程问答-------------------- 不好。
Timer2_Timer() 事件会临时挂起 ProcessDocTask(),在执行途中关闭连接属于分工不明确,这与你避免互相影响的目的冲突。 --------------------编程问答-------------------- 你的qq是多少啊?我能加你吗?我想问清楚些 --------------------编程问答-------------------- 不用判断,直接等待数据传输完成,然后进行相应的操作就可以了啊。 --------------------编程问答-------------------- 一般连接ftp后,连上之后,过多长时间会断开,就是超时时间是多少啊? --------------------编程问答-------------------- RequestTimeout 属性 --------------------编程问答-------------------- 我刚巧做了一个ftp,有这个就可以了。
While Inet1.StillExecuting
DoEvents
Wend
--------------------编程问答-------------------- 你的qq号是多少 啊?我想加你,急啊! --------------------编程问答-------------------- 你的qq号是多少 啊? --------------------编程问答-------------------- 或者你的手机号是多少啊?我想好好问你下啊,急啊!!呵呵 --------------------编程问答-------------------- Private Sub Timer2_Timer()
On Error GoTo errorHandle
m_Timer = m_Timer + 1
If m_Timer > 5 Then
InetRecon.Execute , "CLOSE" '关闭ftp连接'
if isbusy then exit sub '<-
m_Timer = 0
End If
Exit Sub
errorHandle:
MsgBox Err.Description, vbExclamation, "错误提示"
End
End Sub
--------------------编程问答-------------------- 你的qq号是多少啊?我能问你仔细点吗?
补充:VB , 基础类