0
有沒有辦法通過比較文件大小來檢查下載的文件是否已經存在? 以下是我的下載代碼。通過比較文件大小來檢查下載的文件是否存在
Private Sub bgw_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
Dim TestString As String = "http://123/abc.zip," & _
"http://abc/134.zip,"
address = TestString.Split(CChar(",")) 'Split up the file names into an array
'loop through each file to download and create/start a new BackgroundWorker for each one
For Each add As String In address
'get the path and name of the file that you save the downloaded file to
Dim fname As String = IO.Path.Combine("C:\Temp", IO.Path.GetFileName(add))
My.Computer.Network.DownloadFile(add, fname, "", "", False, 60000, True) 'You can change the (False) to True if you want to see the UI
'End If
Next
End Sub
你的意思是你想避免下載不變的文件? – Alireza
@Alireza我想避免下載已完全下載的文件。例如,文件a.zip大小爲160 kb,它被下載並且程序開始下載第二個文件但出現問題,因此用戶需要取消下載操作。然後用戶再次開始下載程序,這次程序會檢查File a.zip是否已經下載,如果是,那麼它會檢查文件大小。 – plokuun