Copy/Overwrite file in destination?

I do need to copy a file and overwrite the destination file if already exists and I do found an old script that it is doing what I need the only issue it is that moves the source file to Recycle Bin and I don’t need that. I removed all the part of the code with if (!Copy) but now the script don’t work anymore.

Can somebody help to modify this script so won’t delete the file from the source folder? (2.7 KB)

      string newPath = Folder + System.IO.Path.GetFileName(File);
      System.IO.File.Copy(File, newPath, true);

Thank you for your effort, however I do get this error now: 1. Error (CS0136): A local variable named 'newPath' cannot be declared in this scope because it would give a different meaning to 'newPath', which is already used in a 'parent or current' scope to denote something else (line 75)

Replace all the code with that

1 Like

Thank you, it is working now.