The Copy method copies an existing file to a new file on the specified location. The Copy method takes three parameters. First the original file with full path, second the file to be copied file name with the new path and third parameter that is optional that is used to overwrite an existing file. If third parameter is true, the Copy method will overwrite if file already exists.
The following code snippet copies the source file to the destination file.
string sourceFile = @"C:\Temp\MaheshTX.txt";
string destinationFile = @"C:\Temp\Data\MaheshTXCopied.txt";
try
{
File.Copy(sourceFile, destinationFile, true);
}
catch (IOException iox)
Console.WriteLine(iox.Message);
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: