Replace File Content
In this chapter you will learn:
File.Replace Replaces contents of file
using System;//from j a v a 2 s . c om
using System.IO;
class FileExample
{
public static void Main()
{
string OriginalFile = "test.xml";
string FileToReplace = "test2.xml";
ReplaceFile(OriginalFile, FileToReplace, "test3.xml");
}
public static void ReplaceFile(string FileToMoveAndDelete, string FileToReplace, string BackupOfFileToReplace)
{
File.Replace(FileToMoveAndDelete, FileToReplace, BackupOfFileToReplace, false);
}
}
Next chapter...
What you will learn in the next chapter: