只要文件不存在,以下代碼就會移動文件。如果有,它不會移動文件。在執行下一行代碼之前是否會執行一行代碼?
我的問題是關於File.Move
。 msgbox何時會顯示?一旦文件完全移動,它會顯示,還是會在File.Move
行執行後立即顯示。
根據文件大小,移動文件可能需要一段時間,因此我不希望msgbox顯示,直到文件完全移動。
有沒有更好的方法來做到這一點?
For Each foundFile As String In My.Computer.FileSystem.GetFiles("C:\Temp\", FileIO.SearchOption.SearchAllSubDirectories, "*.zip")
Dim foundFileInfo As New System.IO.FileInfo(foundFile)
If My.Computer.FileSystem.FileExists("C:\Transfer\" & foundFileInfo.Name) Then
Msgbox("File already exists and will not moved!")
Exit Sub
Else
File.Move(foundFile, "C:\Transfer\" & foundFileInfo.Name)
Msgbox("File has been moved!")
End If
Next
好吧,我有一種感覺它會完成,但想在運行代碼行之前確定。 – Muhnamana