I\'ve got a folder:
c:\\test
I\'m trying this code:
File.Move(@\"c:\\test\\SomeFile.txt\", @\"c:\\test\\Test\");
1) With C# on .Net Core 3.0 and beyond, there is now a third boolean parameter:
see https://docs.microsoft.com/en-us/dotnet/api/system.io.file.move?view=netcore-3.1
In .NET Core 3.0 and later versions, you can call Move(String, String, Boolean) setting the parameter overwrite to true, which will replace the file if it exists.
2) For all other versions of .Net, https://stackoverflow.com/a/42224803/887092 is the best answer. Copy with Overwrite, then delete the source file. This is better because it makes it an atomic operation. (I have attempted to update the MS Docs with this)