Given a file, and we have replace its text with the text of another file, also create a backup file using C# program.
File.Replace()
This is a method of "File" class, it is used to replace 'source-file' with the 'dest-file' by keeping a backup in 'backup-file'.
Syntax:
File.Replace(source-file, dest-file, backup-file);
Parameters:
- source-file - Source file by which we replace destination file.
- dest-file - Destination file which will be replaced by source file.
- backup-file - It is the backup file of Destination file.
-
Program:
Output
Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.
need an explanation for this answer? contact us directly to get an explanation for this answer