C# File Copy(String, String, Boolean)
Description
File Copy(String, String, Boolean)
Copies an existing
file to a new file. Overwriting a file of the same name is allowed.
Syntax
File.Copy(String, String, Boolean)
has the following syntax.
public static void Copy(
string sourceFileName,/* ww w . j a v a 2 s . co m*/
string destFileName,
bool overwrite
)
Parameters
File.Copy(String, String, Boolean)
has the following parameters.
sourceFileName
- The file to copy.destFileName
- The name of the destination file. This cannot be a directory.overwrite
- true if the destination file can be overwritten; otherwise, false.
Returns
File.Copy(String, String, Boolean)
method returns
Example
Copies an existing file to a new file. Overwriting a file of the same name is allowed.
using System;//from w w w . j av a 2s. c o m
using System.IO;
public class MainClass{
public static void Main(String[] argv){
File.Copy("a.txt", "b.txt", true);
}
}