How to create a Copy of a File in the same directory in vb.net

 
You can use the My.Computer.FileSystem.CopyFile method to copy files. this methods also provide parameters that allow you to overwrite existing files, rename the file, show the progress of the operation, and allow the user to cancel the operation.

Create a copy of a file in the same directory

Private Sub CreateCopy()
     My.Computer.FileSystem.CopyFile("C:\TestFolder\test.txt",
                "C:\TestFolder\test2.txt", Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs, FileIO.UICancelOption.DoNothing)
End Sub

Create a copy of a file in the same directory, overwriting existing files

Private Sub CreateCopy()
      My.Computer.FileSystem.CopyFile("C:\TestFolder\test.txt",
                "C:\TestFolder\test2.txt", True)
End Sub