Copying a file from one location to another

In this operation, we basically copy the file from one location and paste it into another. Please note the Move operation will delete the file present in the source folder. However, the Copy operation will copy the file present in the source folder to the destination folder. The following code snippet shows how this can be done:

if (File.Exists(targetFileLocation))
{
File.Copy(targetFileLocation, sourceFileLocation);
}
else
{
Console.WriteLine("File does not exists in the mentioned path");
}

When the code is executed, we will see that the file is copied from the source file location and pasted in to the target file location path.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.188.201