From e672b8c7101beab4b233c9a7eae678daa1e9844c Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Sun, 22 Jun 2025 22:43:44 +0100 Subject: [PATCH 1/2] Remove claim of atomicity from Copy --- xml/System.IO/File.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.IO/File.xml b/xml/System.IO/File.xml index 58488c1784f..4f8bb9a48c2 100644 --- a/xml/System.IO/File.xml +++ b/xml/System.IO/File.xml @@ -3656,7 +3656,7 @@ Note that if you attempt to replace a file by moving a file of the same name int - In .NET Core 3.0 and later versions, you can call setting the parameter `overwrite` to `true`, which will replace the file if it exists. -- In all .NET versions, you can call to copy with overwrite, then call `Delete` to remove the excess source file. This strategy is advisable if the file being copied is small, and you are looking for an "atomic" file operation. If you `Delete` the file first, and the system or program crashes, the destination file will no longer exist. +- In all .NET versions, you can call to copy with overwrite, then call `Delete` to remove the excess source file. This strategy is not atomic, because a system or program crash during the `Copy` may leave a partially-written destination file, but it will ensure a (possibly incomplete) file always exists at the destination. - In all .NET versions, you can call before calling `Move`, which will only delete the file if it exists. From aabf9d938bc7e3e18afa5865a8d8edbdf3b73b4a Mon Sep 17 00:00:00 2001 From: "Andy (Steve) De George" <67293991+adegeo@users.noreply.github.com> Date: Fri, 27 Jun 2025 10:29:27 -0700 Subject: [PATCH 2/2] minor --- xml/System.IO/File.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.IO/File.xml b/xml/System.IO/File.xml index 4f8bb9a48c2..760761c2122 100644 --- a/xml/System.IO/File.xml +++ b/xml/System.IO/File.xml @@ -3656,7 +3656,7 @@ Note that if you attempt to replace a file by moving a file of the same name int - In .NET Core 3.0 and later versions, you can call setting the parameter `overwrite` to `true`, which will replace the file if it exists. -- In all .NET versions, you can call to copy with overwrite, then call `Delete` to remove the excess source file. This strategy is not atomic, because a system or program crash during the `Copy` may leave a partially-written destination file, but it will ensure a (possibly incomplete) file always exists at the destination. +- In all .NET versions, you can call to copy with overwrite, then call `Delete` to remove the excess source file. This strategy isn't atomic, because a system or program crash during the `Copy` may leave a partially-written destination file, but it will ensure a (possibly incomplete) file always exists at the destination. - In all .NET versions, you can call before calling `Move`, which will only delete the file if it exists.