C# File Replace(String, String, String, Boolean)
Description
File Replace(String, String, String, Boolean)
Replaces
the contents of a specified file with the contents of another file, deleting
the original file, and creating a backup of the replaced file and optionally
ignores merge errors.
Syntax
File.Replace(String, String, String, Boolean)
has the following syntax.
public static void Replace(
string sourceFileName,//www.j a va 2s. co m
string destinationFileName,
string destinationBackupFileName,
bool ignoreMetadataErrors
)
Parameters
File.Replace(String, String, String, Boolean)
has the following parameters.
sourceFileName
- The name of a file that replaces the file specified by destinationFileName.destinationFileName
- The name of the file being replaced.destinationBackupFileName
- The name of the backup file.ignoreMetadataErrors
- true to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the replacement file; otherwise, false.
Returns
File.Replace(String, String, String, Boolean)
method returns
Example
using System;// w ww. j a v a2 s . co m
using System.IO;
class FileExample
{
public static void Main()
{
string OriginalFile = "test.xml";
string FileToReplace = "test2.xml";
string BackUpOfFileToReplace = "test2.xml.bac";
File.Replace(OriginalFile, FileToReplace, BackUpOfFileToReplace,false);
}
}