老师,使用FTP设置升级,设置了判断,如果连接不成功,会等好久,才弹出Message的错误提示,有没有什么办法,可以快速提醒FTP连接不成功吗?。
Dim fstr As String = "ftp://UpdateUse:23456@192.168.0.106"
If Fstr.StartsWith("ftp://") Then
fstr = fstr.Replace("ftp://", "")
FileSys.WriteAllText(ProjectPath & "Errlog.txt", vbcrlf & Date.Now & ">>" & fstr , True)
Dim Fs1() As String = fstr.Split("@")
Dim Fs2() As String = Fs1(0).Split(":")
Dim ftp1 As New FtpClient
ftp1.Host = fs1(1)
ftp1.Account = fs2(0)
ftp1.Password = fs2(1)
If ftp1.Connected = False Then'如果FTP没有连接
If ftp1.Connect = False Then '连接FTP
Messagebox.show("连接FTP失败导致升级失败,请检查FTP设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
err = 1
End If
End If
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If err = 0 Then
UpdatePath = s
If Syscmd.Project.Update(False, False) = False Then
end if