File class provides functionality to copy a file in C#. The File.Copy method copies an existing file to a new file in the specified location.
The File.Copy method takes three parameters. First, the original file with the full path. The second is the file to be copied file name with the new path, and the third parameter is optional and is used to overwrite an existing file. If the third parameter is true, the Copy method will overwrite if the 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);
}
Here is a Complete Tutorial On Working With Files In C#.
Alternatively, we can use a FileInfo class's CopyTo or MoveTo method. Learn more here on Working with FileInfo Class In C#.

Chris CarioPosted Jan 23, 2023, 4:28 PM
What if you want to copy files with similar beginnings? Like say LogFile2* where the "*" represents other characters. So we know it starts with LogFile2, just not what's after it.
Pankajkumar PatelPosted Aug 26, 2019, 11:56 PM
Good article
Sonu GuptaPosted Aug 26, 2019, 12:43 AM
Informative..
Aubrey LovePosted Mar 14, 2019, 11:26 AM
I am trying to learn everything I can about "FileInfo" and manipulating files using C#. I would love a good reference for this. The examples like this one don't really help a newbie in the C# world, I don't want to copy "A" file, I want to copy multiple files and folders all at once. Can you please provide samples of that?
Dharmendra Kumar PanditPosted Jun 26, 2018, 4:51 AM
Thank you to share this type of info. Its working fine.