public static Copy ( String sourceFileName, String destFileName ) : void | ||
sourceFileName | String | |
destFileName | String | |
return | void |
// Copy the file from the source path to the target path string sourcePath = @"C:\Source\example.txt"; string targetPath = @"D:\Target\example.txt"; File.Copy(sourcePath, targetPath);
// Copy the file from the source path to the target path and overwrite if it already exists string sourcePath = @"C:\Source\example.txt"; string targetPath = @"D:\Target\example.txt"; File.Copy(sourcePath, targetPath, true);In this example, the third parameter of the File.Copy method is used to specify if the file should be overwritten if it already exists in the target path. Package Library: System.IO.FileSystem.
public static Copy ( String sourceFileName, String destFileName ) : void | ||
sourceFileName | String | |
destFileName | String | |
return | void |