次のコードは、ファイルがまだ存在しない限り、ファイルを移動しています。その場合、ファイルは移動されません。
私の質問は に関するものFile.Move
です。メッセージボックスはいつ表示されますか? File.Move
ファイルが完全に移動されると表示されますか、それとも行が実行された直後に表示されますか。
ファイルのサイズによっては、ファイルの移動に時間がかかる場合があるため、ファイルが完全に移動されるまでメッセージボックスを表示したくありません。
これを行うより良い方法はありますか?
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