Moving a file to another location within seconds:
Items Needed:
Button
Names of controls needed:
<Any name you like>
Code:
'Declare the variables
Dim FileOrig As String
Dim FileNewLocation As String
'Set the variables with the locations that you need to move to
'bear in mind that where you are moving to needs to exist on your drive already!
FileOrig = "C:\text.txt"
FileNewLocation = "C:\Test Folder\NewText.txt"
'Check to see if the file exists
If System.IO.File.Exists(FileOrig) = True Then
'Move the file to the new location
System.IO.File.Move(FileOrig, FileNewLocation)
'Say that it was completed successfully
MsgBox("Your file was moved")
else
'If there was an error, display that there was an error
msgbox ("Your file wasnt moved")
'end the IF statement
End If