Question Replacing a file

you coudl simplify by using this:

try
'Source file
Dim sFile As String = "C:\Source.File.exe"
'Destination File
Dim dFile As String = "C:\Destination.File.exe"
'Backup File *Optional*
Dim bFile As String = "C:\BakupFile.exe"
'Check File *Not needed* you could use "sfile"
Dim cFile As String = "C:\SomeFile.exe"
'check if file is Exsisting
If IO.File.Exists(cFile) = True Then
'File Replaced
IO.File.Replace(sFile, dFile, bFile)
'Line Bellow using the True Boolean in
'the last part is a Overwite method with out Backing up
'IO.File.Copy(sFile, dFile, True)
Else
'File Copied
IO.File.Copy(sFile, dFile)
End If
Catch ex as exception
end try
I haven't tested this but it should work fine
 
Back
Top