It is my first time to write code to function file operations. I need to compare old file with a new file. If the old file name is equal to a new file name, it needs to be overwritten (update). If not equal, creating a new file name. How to do this in a simple and best way?
public void FileCreateOrOverwritten(string file)
{
    try
    {
        if (File.Exists(file))
        {
            if (file == newFile)
            {
                //how to replace old file with a new one with new data (xml document)
                //need to use filestream
            }
            else
            {
                //how to create a new file with new data (xml document)
            }
        }
        .
        .
        .
    }
 
     
    