我使用Xceed.Ftp.FtpClient()下载FTP文件,如何计算估计的剩余时间?
Dim HostName As String =(New Uri(RemoteFilePath).Host).ToString()
Dim RemoteFolderName As String = System.IO.Path.GetFileName((New Uri(RemoteFilePath).LocalPath).ToString())
Dim RemoteFileName As String = System.IO.Path.GetFileName((New Uri(RemoteFilePath).LocalPath).ToString())
Dim LocalFileName As String = System.IO.Path.GetFileName((New Uri(LocalFilePath).LocalPath).ToString())
Dim Ftp As New Xceed.Ftp.FtpClient()
Dim AuthMethod As AuthenticationMethod = AuthenticationMethod.Tls
Dim VeriFlag As VerificationFlags = VerificationFlags.None
Dim Cert As Certificate = Nothing
Ftp.Connect(HostName, 990, AuthMethod, VeriFlag, Cert)
'Console.WriteLine("Connected")
Ftp.Login(username, pass)
Dim s As String = Ftp.GetCurrentFolder()
'Console.WriteLine("LogedIn")
Ftp.ChangeCurrentFolder("WindowsPatches/" & RemoteFolderName)
'Console.WriteLine("Remote Folder Name:" & RemoteFolderName)
'Ftp.ChangeCurrentFolder(RemoteFolderName)
Dim files = Ftp.GetFolderContents()
If files IsNot Nothing AndAlso files.Count >= 0 Then
For index = 0 To files.Count - 1
If files.Item(index).Type = FtpItemType.File Then
RemoteFileName = files.Item(index).Name
LocalFileName = RemoteFileName
If Not Directory.Exists(RemoteFolderName) Then
Directory.CreateDirectory(RemoteFolderName)
End If
LocalFileName = RemoteFolderName & "\" & LocalFileName
If Not String.IsNullOrEmpty(LocalFilePath) AndAlso System.IO.File.Exists(LocalFilePath) Then
System.IO.File.Delete(LocalFilePath)
End If
'Console.WriteLine("Downloading started...")
Ftp.ReceiveFile(RemoteFileName, LocalFileName)
'Console.WriteLine("Downloading Complete")
'Console.WriteLine("Working Path" & Directory.GetCurrentDirectory())
Dim psi As New ProcessStartInfo()
Directory.SetCurrentDirectory(LocalFilePath & RemoteFolderName)
'Console.WriteLine("Local Directory Name: " & LocalFilePath & RemoteFolderName)
psi.CreateNoWindow = True
psi.FileName = RemoteFileName
psi.UseShellExecute = True
Dim myProcess As Process = Process.Start(psi)
Console.WriteLine("Update process started...")
'Exit For
End If
Next
'LocalFileName = RemoteFileName
End If
我正在使用此代码,有什么建议吗?